Class: GoogleCells::GoogleObject
- Inherits:
-
Object
- Object
- GoogleCells::GoogleObject
- Defined in:
- lib/google_cells/google_object.rb
Class Attribute Summary collapse
-
.permanent_attributes ⇒ Object
readonly
Returns the value of attribute permanent_attributes.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attribs = {}) ⇒ GoogleObject
constructor
A new instance of GoogleObject.
Constructor Details
#initialize(attribs = {}) ⇒ GoogleObject
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/google_cells/google_object.rb', line 16 def initialize(attribs={}) @values = {} self.class.permanent_attributes.each{|a| @values[a] = attribs[a]} extra = attribs.keys - self.class.permanent_attributes extra.each do |a| if self.respond_to?("#{a}=") instance_variable_set("@#{a}".to_sym, attribs[a]) next end raise ArgumentError, "invalid attribute #{a} passed to #{ self.class}" end end |
Class Attribute Details
.permanent_attributes ⇒ Object (readonly)
Returns the value of attribute permanent_attributes.
5 6 7 |
# File 'lib/google_cells/google_object.rb', line 5 def permanent_attributes @permanent_attributes end |
Class Method Details
.define_accessors ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/google_cells/google_object.rb', line 7 def define_accessors self.instance_eval do @permanent_attributes.each do |k| define_method(k){ @values[k] } end end end |