Module: SimpleFormObject::ClassMethods
- Defined in:
- lib/simple_form_object.rb
Instance Method Summary collapse
- #_attribute(attribute_name) ⇒ Object
- #_attributes ⇒ Object
- #attribute(name, type = :string, options = {}) ⇒ Object
- #model_name ⇒ Object
Instance Method Details
#_attribute(attribute_name) ⇒ Object
21 22 23 |
# File 'lib/simple_form_object.rb', line 21 def _attribute(attribute_name) _attributes.select{|a| a.name == attribute_name}.first end |
#_attributes ⇒ Object
17 18 19 |
# File 'lib/simple_form_object.rb', line 17 def _attributes @_attributes ||= [] end |
#attribute(name, type = :string, options = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/simple_form_object.rb', line 11 def attribute(name, type = :string, = {}) self.send(:attr_accessor, name) _attributes << Attribute.new(name, type, ) end |
#model_name ⇒ Object
25 26 27 |
# File 'lib/simple_form_object.rb', line 25 def model_name ActiveModel::Name.new(self, nil, self.to_s.gsub(/Form$/, '')) end |