Module: Nem::Mixin::Assignable

Instance Method Summary collapse

Instance Method Details

#initialize(attributes = {}) {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



4
5
6
7
8
9
10
11
12
# File 'lib/nem/mixin/assignable.rb', line 4

def initialize(attributes = {})
  attributes.each do |k, v|
    instance_variable_set("@#{k.to_s}", v) if respond_to?("#{k.to_s}")
    if !respond_to?("#{k.to_s}")
      Nem.logger.warn "Detected unknown key-value. #{k} => #{v} while assigning #{self.class.name}"
    end
  end if attributes
  yield self if block_given?
end