Module: ActiveRecord::Has::CustomFields::InstanceMethods

Defined in:
lib/has_custom_fields.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

:nodoc:



204
205
206
# File 'lib/has_custom_fields.rb', line 204

def self.included(base) # :nodoc:
  base.extend ClassMethods
end

Instance Method Details

#custom_fieldsObject



304
305
306
# File 'lib/has_custom_fields.rb', line 304

def custom_fields
  return ScopeFacade.new(self)
end

#custom_fields=(custom_fields_data) ⇒ Object



294
295
296
297
298
299
300
301
302
# File 'lib/has_custom_fields.rb', line 294

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|
        self.set_custom_field_attribute(k, v, scope, scope_id)
      end
    end
  end
end

#get_custom_field_attribute(attribute_name, scope, scope_id) ⇒ Object



286
287
288
# File 'lib/has_custom_fields.rb', line 286

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



290
291
292
# File 'lib/has_custom_fields.rb', line 290

def set_custom_field_attribute(attribute_name, value, scope, scope_id)
  write_attribute_with_custom_field_behavior(attribute_name, value, scope, scope_id)
end