Module: Lean::Attributes::Initializer

Defined in:
lib/lean-attributes/attributes/initializer.rb

Overview

Adds an #initialize method that sets attribute values based on Hash keys-values

Since:

  • 0.0.1

Instance Method Summary collapse

Instance Method Details

#initialize(attributes = {}) ⇒ Object

Assigns Hash values to attributes based on key names

Parameters:

  • attributes (Hash) (defaults to: {})

Returns:

  • (Object)

    instance of inclusive class with attributes set

Since:

  • 0.0.1



13
14
15
16
17
# File 'lib/lean-attributes/attributes/initializer.rb', line 13

def initialize(attributes = {})
  attributes.each do |name, value|
    send(:"#{name}=", value)
  end
end