Module: SmoothOperator::AttributeAssignment

Included in:
OpenStruct
Defined in:
lib/smooth_operator/attribute_assignment.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_meta_dataObject (readonly)

Returns the value of attribute _meta_data.



14
15
16
# File 'lib/smooth_operator/attribute_assignment.rb', line 14

def 
  @_meta_data
end

#_optionsObject (readonly)

Returns the value of attribute _options.



14
15
16
# File 'lib/smooth_operator/attribute_assignment.rb', line 14

def _options
  @_options
end

Instance Method Details

#assign_attributes(attributes = {}, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/smooth_operator/attribute_assignment.rb', line 16

def assign_attributes(attributes = {}, options = {})
  attributes = _extract_attributes(attributes)

  return nil unless attributes.is_a?(Hash)

  induce_errors(attributes.delete(self.class.errors_key))

  @_options.merge!(options) if options.is_a? Hash

  attributes.each do |name, value|
    next unless allowed_attribute(name)

    send("#{name}=", value)
  end
end

#initialize(attributes = {}, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/smooth_operator/attribute_assignment.rb', line 4

def initialize(attributes = {}, options = {})
  @_options = {}

  before_initialize(attributes, options)

  assign_attributes(attributes, options)

  after_initialize(attributes, options)
end