|
|
@ -65,21 +65,19 @@ module API |
|
|
|
|
|
|
|
|
|
|
|
class << self |
|
|
|
class << self |
|
|
|
def create_value_representer(customizable, representer) |
|
|
|
def create_value_representer(customizable, representer) |
|
|
|
injector = CustomFieldInjector.new(representer) |
|
|
|
new_representer_class_with(representer, customizable) do |injector| |
|
|
|
customizable.available_custom_fields.each do |custom_field| |
|
|
|
customizable.available_custom_fields.each do |custom_field| |
|
|
|
injector.inject_value(custom_field, embed_links: true) |
|
|
|
injector.inject_value(custom_field, embed_links: true) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
injector.modified_representer_class |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def create_schema_representer(customizable, representer) |
|
|
|
def create_schema_representer(customizable, representer) |
|
|
|
injector = CustomFieldInjector.new(representer) |
|
|
|
new_representer_class_with(representer, customizable) do |injector| |
|
|
|
customizable.available_custom_fields.each do |custom_field| |
|
|
|
customizable.available_custom_fields.each do |custom_field| |
|
|
|
injector.inject_schema(custom_field, customized: customizable) |
|
|
|
injector.inject_schema(custom_field, customized: customizable) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
injector.modified_representer_class |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def create_value_representer_for_property_patching(customizable, representer) |
|
|
|
def create_value_representer_for_property_patching(customizable, representer) |
|
|
@ -87,12 +85,11 @@ module API |
|
|
|
property_field?(cf) |
|
|
|
property_field?(cf) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
injector = CustomFieldInjector.new(representer) |
|
|
|
new_representer_class_with(representer, customizable) do |injector| |
|
|
|
property_fields.each do |custom_field| |
|
|
|
property_fields.each do |custom_field| |
|
|
|
injector.inject_value(custom_field) |
|
|
|
injector.inject_value(custom_field) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
injector.modified_representer_class |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def create_value_representer_for_link_patching(customizable, representer) |
|
|
|
def create_value_representer_for_link_patching(customizable, representer) |
|
|
@ -100,12 +97,11 @@ module API |
|
|
|
linked_field?(cf) |
|
|
|
linked_field?(cf) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
injector = CustomFieldInjector.new(representer) |
|
|
|
new_representer_class_with(representer, customizable) do |injector| |
|
|
|
linked_fields.each do |custom_field| |
|
|
|
linked_fields.each do |custom_field| |
|
|
|
injector.inject_patchable_link_value(custom_field) |
|
|
|
injector.inject_patchable_link_value(custom_field) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
injector.modified_representer_class |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def linked_field?(custom_field) |
|
|
|
def linked_field?(custom_field) |
|
|
@ -115,10 +111,26 @@ module API |
|
|
|
def property_field?(custom_field) |
|
|
|
def property_field?(custom_field) |
|
|
|
!linked_field?(custom_field) |
|
|
|
!linked_field?(custom_field) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def new_representer_class_with(representer, customizable, &block) |
|
|
|
|
|
|
|
injector = new(representer, customizable) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
block.call injector |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
injector.modified_representer_class |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def initialize(representer_class) |
|
|
|
def initialize(representer_class, customizable) |
|
|
|
@class = Class.new(representer_class) |
|
|
|
@class = Class.new(representer_class) do |
|
|
|
|
|
|
|
class << self |
|
|
|
|
|
|
|
attr_accessor :customizable |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@class.customizable = customizable |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@class |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def modified_representer_class |
|
|
|
def modified_representer_class |
|
|
|