module FatFreeCRM::Fields::InstanceMethods

Public Instance Methods

assign_attributes(new_attributes) click to toggle source
Calls superclass method
# File lib/fat_free_crm/fields.rb, line 67
def assign_attributes(new_attributes)
  super
# If attribute is unknown, a new custom field may have been added.
# Refresh columns and try again.
rescue ActiveRecord::UnknownAttributeError
  self.class.reset_column_information
  super
end
custom_fields_validator() click to toggle source

run custom field validations on this object

# File lib/fat_free_crm/fields.rb, line 63
def custom_fields_validator
  field_groups.map(&:fields).flatten.each { |f| f.custom_validator(self) }
end
field_groups() click to toggle source
# File lib/fat_free_crm/fields.rb, line 56
def field_groups
  field_groups = self.class.field_groups
  respond_to?(:tag_ids) ? field_groups.with_tags(tag_ids) : field_groups
end
method_missing(method_id, *args, &block) click to toggle source
Calls superclass method
# File lib/fat_free_crm/fields.rb, line 76
def method_missing(method_id, *args, &block)
  if method_id.to_s.match?(/\Acf_.*[^=]\Z/)
    # Refresh columns and try again.
    self.class.reset_column_information
    # If new record, create new object from class, else reload class
    object = new_record? ? self.class.new : (reload && self)
    # ensure serialization is setup if needed
    self.class.serialize_custom_fields!
    # Try again if object now responds to method, else return nil
    object.respond_to?(method_id) ? object.send(method_id, *args) : nil
  else
    super
  end
end