Module: WargamingApi::Concern::Attributable

Included in:
Node
Defined in:
lib/wargaming_api/concern/attributable.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/wargaming_api/concern/attributable.rb', line 2

def self.included(base)
  base.extend ClassMethods
  base.class_eval do
    cattr_accessor :_attributes
    self._attributes = {}
  end
end

Instance Method Details

#apply_type(name, value) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/wargaming_api/concern/attributable.rb', line 16

def apply_type(name, value)
  return value if value.nil?

  case self._attributes[name.to_sym]
  when :datetime
    Time.at(value)
  else
    value
  end
end