Class: Yelp::Record
- Inherits:
-
Object
- Object
- Yelp::Record
- Defined in:
- lib/yelped/record.rb
Overview
General-purpose record that allows passing a hash with parameters to populate object attributes defined via methods like attr_reader
or attr_accessor
.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(params) ⇒ Record
constructor
A new instance of Record.
Constructor Details
#initialize(params) ⇒ Record
Returns a new instance of Record.
7 8 9 10 11 12 13 14 |
# File 'lib/yelped/record.rb', line 7 def initialize (params) if !params.nil? params.each do |key, value| name = key.to_s instance_variable_set("@#{name}", value) if respond_to?(name) end end end |