Module: Packet::Entity::Base

Extended by:
ActiveSupport::Concern
Defined in:
lib/packet/entity/base.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#clientObject



32
33
34
# File 'lib/packet/entity/base.rb', line 32

def client
  @client || Packet.client
end

#initialize(attributes = {}, client = nil) ⇒ Object



20
21
22
23
# File 'lib/packet/entity/base.rb', line 20

def initialize(attributes = {}, client = nil)
  self.client = client
  update_attributes(attributes)
end

#update_attributes(attributes = {}) ⇒ Object



25
26
27
28
29
30
# File 'lib/packet/entity/base.rb', line 25

def update_attributes(attributes = {})
  attributes.each_pair do |attribute, value|
    setter = "#{attribute}="
    send(setter, _cast_value(attribute, value)) if respond_to?(setter)
  end
end