module LunaPark::Extensions::Attributable

@example

class Account
  include LunaPark::Extensions::Attributable

  attr_accessor :type, :id

  def initialize(hash)
    set_attributes(hash) # method included by mixin (private)
  end
end

Account.new(type: 'user', id: 42) # => #<Account type="user" id=42>

Private Instance Methods

set_attributes(hash) click to toggle source
# File lib/luna_park/extensions/attributable.rb, line 20
def set_attributes(hash) # rubocop:disable Naming/AccessorMethodName
  hash.each_pair { |k, v| send(:"#{k}=", v) }
  self
end