Sha256: ac79e919b8f340e1010e1d172dfc4151177629ccb0dae7d6d77734b2b740b834

Contents?: true

Size: 464 Bytes

Versions: 2

Compression:

Stored size: 464 Bytes

Contents

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

  module ClassMethods
    def attribute(name, type)
      _attributes[name] = type
    end
  end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wargaming_api_ruby-0.1.1 lib/wargaming_api/concern/attributable.rb
wargaming_api_ruby-0.1.0 lib/wargaming_api/concern/attributable.rb