Module: HasCustomFields::InstanceMethods
- Defined in:
- lib/has_custom_fields/instance_methods.rb
Instance Method Summary collapse
- #custom_fields ⇒ Object
- #custom_fields=(custom_fields_data) ⇒ Object
- #get_custom_field_attribute(attribute_name, scope, scope_id) ⇒ Object
- #set_custom_field_attribute(attribute_name, value, scope, scope_id) ⇒ Object
Instance Method Details
#custom_fields ⇒ Object
27 28 29 |
# File 'lib/has_custom_fields/instance_methods.rb', line 27 def custom_fields return ScopeFacade.new(self) end |
#custom_fields=(custom_fields_data) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/has_custom_fields/instance_methods.rb', line 12 def custom_fields=(custom_fields_data) custom_fields_data.each do |scope, scoped_ids| scoped_ids.each do |scope_id, attrs| attrs.each do |k, v| if v.blank? value_object = get_value_object(k, scope, scope_id) value_object.delete else self.set_custom_field_attribute(k, v, scope, scope_id) end end end end end |
#get_custom_field_attribute(attribute_name, scope, scope_id) ⇒ Object
4 5 6 |
# File 'lib/has_custom_fields/instance_methods.rb', line 4 def get_custom_field_attribute(attribute_name, scope, scope_id) read_attribute_with_custom_field_behavior(attribute_name, scope, scope_id) end |
#set_custom_field_attribute(attribute_name, value, scope, scope_id) ⇒ Object
8 9 10 |
# File 'lib/has_custom_fields/instance_methods.rb', line 8 def set_custom_field_attribute(attribute_name, value, scope, scope_id) write_attribute_with_custom_field_behavior(attribute_name, value, scope, scope_id) end |