Class: Qapi::Model
- Inherits:
-
Object
- Object
- Qapi::Model
- Defined in:
- lib/qapi/model.rb
Class Attribute Summary collapse
-
.attrs ⇒ Object
Returns the value of attribute attrs.
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(connection, attrs = {}) ⇒ Model
constructor
A new instance of Model.
- #inspect ⇒ Object
Constructor Details
#initialize(connection, attrs = {}) ⇒ Model
Returns a new instance of Model.
16 17 18 19 20 21 |
# File 'lib/qapi/model.rb', line 16 def initialize(connection, attrs = {}) @connection = connection self.class.attrs.each do |attr| self.send("#{attr}=", attrs[attr]) end end |
Class Attribute Details
.attrs ⇒ Object
Returns the value of attribute attrs.
7 8 9 |
# File 'lib/qapi/model.rb', line 7 def attrs @attrs end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
4 5 6 |
# File 'lib/qapi/model.rb', line 4 def connection @connection end |
Class Method Details
.attribute(name) ⇒ Object
10 11 12 13 14 |
# File 'lib/qapi/model.rb', line 10 def self.attribute(name) self.send(:attr_accessor, name) self.attrs ||= [] self.attrs << name.to_s end |
Instance Method Details
#inspect ⇒ Object
23 24 25 26 27 |
# File 'lib/qapi/model.rb', line 23 def inspect "<" + self.class.attrs.map do |attr| "#{attr}: #{send(attr)}" end.join(", ") + ">" end |