Class: FatZebra::Models::Base
- Inherits:
-
Object
- Object
- FatZebra::Models::Base
- Defined in:
- lib/fat_zebra/models/base.rb
Constant Summary collapse
- @@attributes =
[]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ Base
Returns a new instance of Base.
13 14 15 16 17 18 19 |
# File 'lib/fat_zebra/models/base.rb', line 13 def initialize(attrs = {}) attrs.each do |key, val| self.send("#{key}=", val) if self.respond_to?("#{key}=") end self.raw = attrs if self.respond_to?(:raw=) end |
Class Method Details
.attribute(*values) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fat_zebra/models/base.rb', line 5 def self.attribute(*values) @@attributes ||= [] values.each do |val| @@attributes << val end attr_accessor *values end |
Instance Method Details
#inspect ⇒ Object
21 22 23 24 25 26 |
# File 'lib/fat_zebra/models/base.rb', line 21 def inspect inspection = @@attributes.collect { |name| "#{name}: #{instance_variable_get("@#{name}")}" }.compact.join(", ") "#<#{self.class} #{inspection}>" end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/fat_zebra/models/base.rb', line 28 def to_s inspect end |