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

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

#_attributesObject



26
27
28
# File 'lib/simple_form_object.rb', line 26

def _attributes
  @_attributes ||= []
end

#_delegation_targetObject



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, options = {})
  self.send(:attr_accessor, name)

  _attributes << Attribute.new(name, options, type)
end

#attributesObject



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(options = {})
  @_delegation_target = options.fetch(:to)
end

#model_nameObject



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