OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/config/initializers/representable_patch.rb

27 lines
704 B

require 'representable'
module OpenProject::RepresentablePatch
def self.included(base)
base.class_eval do
def self.as_strategy=(strategy)
raise 'The :as_strategy option should respond to #call?' unless strategy.respond_to?(:call)
@as_strategy = strategy
end
def self.as_strategy
@as_strategy
end
def self.property(name, options = {}, &block)
options = { as: as_strategy.call(name.to_s) }.merge(options) if as_strategy
super
end
end
end
end
unless Representable::Decorator.included_modules.include?(OpenProject::RepresentablePatch)
Representable::Decorator.send(:include, OpenProject::RepresentablePatch)
end