Class: Uber::Base
- Inherits:
-
Object
- Object
- Uber::Base
- Defined in:
- lib/uber/base.rb
Direct Known Subclasses
Activity, City, Delivery::Delivery, Delivery::Quote, Delivery::Rating, Delivery::RatingTag, Delivery::Receipt, Delivery::Region, Driver, Estimate, History, Location, Map, Partner::Partner, Partner::Payment, Partner::PaymentActivity, Partner::StatusChange, Partner::Trip, Partner::TripActivity, Place, Price, Product, Promotion, Receipt, Reminder, Reminder::Event, Reminder::TripBranding, Request, RequestError, Time, Token, Trip, User, Vehicle
Instance Attribute Summary collapse
-
#attrs ⇒ Object
(also: #to_h)
readonly
Returns the value of attribute attrs.
Instance Method Summary collapse
-
#[](method) ⇒ Object
Fetches an attribute of an object using hash notation.
-
#initialize(attrs = {}) ⇒ Uber::Base
constructor
Initializes a new object.
Constructor Details
#initialize(attrs = {}) ⇒ Uber::Base
Initializes a new object
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
#attrs ⇒ Object (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
22 23 24 25 26 |
# File 'lib/uber/base.rb', line 22 def [](method) send(method.to_sym) rescue NoMethodError nil end |