Module: SimpleFormObject::ClassMethods
- Defined in:
- lib/simple_form_object.rb
Instance Method Summary collapse
- #_attribute(attribute_name) ⇒ Object
- #_attributes ⇒ Object
- #_delegation_target ⇒ Object
- #attribute(name, type = :string, options = {}) ⇒ Object
- #delegate_all(options = {}) ⇒ Object
- #model_name ⇒ Object
Instance Method Details
#_attribute(attribute_name) ⇒ Object
28 29 30 |
# File 'lib/simple_form_object.rb', line 28 def _attribute(attribute_name) _attributes.select{|a| a.name == attribute_name}.first end |
#_attributes ⇒ Object
24 25 26 |
# File 'lib/simple_form_object.rb', line 24 def _attributes @_attributes ||= [] end |
#_delegation_target ⇒ Object
20 21 22 |
# File 'lib/simple_form_object.rb', line 20 def _delegation_target @_delegation_target end |
#attribute(name, type = :string, options = {}) ⇒ Object
10 11 12 13 14 |
# File 'lib/simple_form_object.rb', line 10 def attribute(name, type = :string, = {}) self.send(:attr_accessor, name) _attributes << Attribute.new(name, type, ) end |
#delegate_all(options = {}) ⇒ Object
16 17 18 |
# File 'lib/simple_form_object.rb', line 16 def delegate_all( = {}) @_delegation_target = .fetch(:to) end |
#model_name ⇒ Object
32 33 34 |
# File 'lib/simple_form_object.rb', line 32 def model_name ActiveModel::Name.new(self, nil, self.to_s.gsub(/Form$/, '')) end |