Class: Uber::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/uber/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Uber::Base

Initializes a new object

Parameters:

  • attrs (Hash) (defaults to: {})


10
11
12
13
14
15
16
17
# File 'lib/uber/base.rb', line 10

def initialize(attrs = {})
  return if attrs.nil? || attrs.empty?
  attrs.each do |key, value|
    if respond_to?(:"#{key}=")
      send(:"#{key}=", value)
    end
  end
end

Instance Attribute Details

#attrsObject (readonly) Also known as: to_h

Returns the value of attribute attrs.



3
4
5
# File 'lib/uber/base.rb', line 3

def attrs
  @attrs
end

Instance Method Details

#[](method) ⇒ Object

Fetches an attribute of an object using hash notation

Parameters:

  • method (String, Symbol)

    Message to send to the object



22
23
24
25
26
# File 'lib/uber/base.rb', line 22

def [](method)
  send(method.to_sym)
rescue NoMethodError
  nil
end