Module: Filemaker::Model::Fields::ClassMethods
- Defined in:
- lib/filemaker/model/fields.rb
Instance Method Summary collapse
- #add_field(name, type, options) ⇒ Object
- #attribute_names ⇒ Object
- #create_accessors(name) ⇒ Object
-
#find_field_by_name(name) ⇒ Object
Find FileMaker’s real name given either the attribute name or the real FileMaker name.
Instance Method Details
#add_field(name, type, options) ⇒ Object
55 56 57 58 |
# File 'lib/filemaker/model/fields.rb', line 55 def add_field(name, type, ) fields[name] = Filemaker::Model::Field.new(name, type, ) self.identity = fields[name] if [:identity] end |
#attribute_names ⇒ Object
38 39 40 |
# File 'lib/filemaker/model/fields.rb', line 38 def attribute_names fields.keys end |
#create_accessors(name) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/filemaker/model/fields.rb', line 60 def create_accessors(name) define_method(name) { attributes[name] } define_method("#{name}=") do |value| attributes[name] = fields[name].coerce(value) end define_method("#{name}?") do attributes[name] == true || attributes[name].present? end end |
#find_field_by_name(name) ⇒ Object
Find FileMaker’s real name given either the attribute name or the real FileMaker name.
72 73 74 75 76 |
# File 'lib/filemaker/model/fields.rb', line 72 def find_field_by_name(name) fields.values.find do |f| f.name == name.to_sym || f.fm_name == name.to_s end end |