Class: BingSearch::Model
- Inherits:
-
Object
- Object
- BingSearch::Model
- Defined in:
- lib/bing-search/models.rb
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Model
constructor
A new instance of Model.
-
#set(attr, value) ⇒ self
Sets an attribute via a public instance method on the receiver or its ancestors up to but not including Object.
Constructor Details
#initialize(attrs = {}) ⇒ Model
Returns a new instance of Model.
5 6 7 8 9 |
# File 'lib/bing-search/models.rb', line 5 def initialize(attrs = {}) attrs.each do |k, v| public_send "#{k}=", v end end |
Instance Method Details
#set(attr, value) ⇒ self
Sets an attribute via a public instance method on the receiver or its ancestors up to but not including Object
20 21 22 23 24 25 26 |
# File 'lib/bing-search/models.rb', line 20 def set(attr, value) setter = "#{attr}=".to_sym self.class.attr_methods.include?(setter) ? public_send(setter, value) : raise(ArgumentError, "Can't set attr #{attr} of #{self}") end |