Module: FatFreeCRM::Fields::InstanceMethods
- Defined in:
- lib/fat_free_crm/fields.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *args, &block) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/fat_free_crm/fields.rb', line 76
def method_missing(method_id, *args, &block)
if method_id.to_s.match?(/\Acf_.*[^=]\Z/)
self.class.reset_column_information
object = new_record? ? self.class.new : (reload && self)
self.class.serialize_custom_fields!
object.respond_to?(method_id) ? object.send(method_id, *args) : nil
else
super
end
end
|
Instance Method Details
#assign_attributes(new_attributes) ⇒ Object
67
68
69
70
71
72
73
74
|
# File 'lib/fat_free_crm/fields.rb', line 67
def assign_attributes(new_attributes)
super
rescue ActiveRecord::UnknownAttributeError
self.class.reset_column_information
super
end
|
#custom_fields_validator ⇒ Object
run custom field validations on this object
63
64
65
|
# 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 ⇒ Object
56
57
58
59
|
# 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
|