Module: SimpleFormObject::ClassMethods
- Defined in:
- lib/simple_form_object.rb
Overview
TODO: There are a number of self. calls that rubocop claims are redundant in this file that need to be investigated. rubocop:disable Style/RedundantSelf
Instance Method Summary collapse
- #_attribute(attribute_name) ⇒ Object
- #_attributes ⇒ Object
- #_delegation_target ⇒ Object
- #attribute(name, type = :string, options = {}) ⇒ Object
- #attributes ⇒ Object
- #delegate_all(options = {}) ⇒ Object
- #model_name ⇒ Object
Instance Method Details
#_attribute(attribute_name) ⇒ Object
34 35 36 |
# File 'lib/simple_form_object.rb', line 34 def _attribute(attribute_name) _attributes.select { |a| a.name == attribute_name }.first end |
#_attributes ⇒ Object
26 27 28 |
# File 'lib/simple_form_object.rb', line 26 def _attributes @_attributes ||= [] end |
#_delegation_target ⇒ Object
22 23 24 |
# File 'lib/simple_form_object.rb', line 22 def _delegation_target @_delegation_target end |
#attribute(name, type = :string, options = {}) ⇒ Object
12 13 14 15 16 |
# File 'lib/simple_form_object.rb', line 12 def attribute(name, type = :string, = {}) self.send(:attr_accessor, name) _attributes << Attribute.new(name, , type) end |
#attributes ⇒ Object
30 31 32 |
# File 'lib/simple_form_object.rb', line 30 def attributes @_attributes end |
#delegate_all(options = {}) ⇒ Object
18 19 20 |
# File 'lib/simple_form_object.rb', line 18 def delegate_all( = {}) @_delegation_target = .fetch(:to) end |
#model_name ⇒ Object
38 39 40 |
# File 'lib/simple_form_object.rb', line 38 def model_name ActiveModel::Name.new(self, nil, self.to_s.gsub(/Step$/, "")) end |