Class: Smite::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/smite/object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Object

Returns a new instance of Object.



5
6
7
8
9
10
# File 'lib/smite/object.rb', line 5

def initialize(data)
  @data = data.each_with_object({}) do |(k, v), obj|
    next if k == 'ret_msg'
    obj[ActiveSupport::Inflector.underscore(k)] = v
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



16
17
18
19
# File 'lib/smite/object.rb', line 16

def method_missing(method)
  camel_method = ActiveSupport::Inflector.underscore(method.to_s)
  @data.include?(camel_method) ? @data[camel_method] : super
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/smite/object.rb', line 3

def data
  @data
end

Instance Method Details

#attributesObject



12
13
14
# File 'lib/smite/object.rb', line 12

def attributes
  @data.keys
end