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: {})


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

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.



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

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



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

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