Class: MediaMonster::Model
- Inherits:
-
Object
- Object
- MediaMonster::Model
- Defined in:
- lib/media_monster/model.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #as_json_with_class_name(options = {}) ⇒ Object (also: #as_json)
-
#initialize(*args) ⇒ Model
constructor
A new instance of Model.
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Model
Returns a new instance of Model.
8 9 10 11 12 13 |
# File 'lib/media_monster/model.rb', line 8 def initialize(*args) return unless args if args[0].is_a?(Hash) args[0].each { |k,v| self.send("#{k.to_s}=".to_sym, v) } end end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/media_monster/model.rb', line 5 def id @id end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/media_monster/model.rb', line 6 def status @status end |
Instance Method Details
#as_json_with_class_name(options = {}) ⇒ Object Also known as: as_json
16 17 18 |
# File 'lib/media_monster/model.rb', line 16 def as_json_with_class_name(={}) {self.class.name.demodulize.underscore.to_sym => as_json_without_class_name()} end |
#to_json(options = {}) ⇒ Object
24 25 26 |
# File 'lib/media_monster/model.rb', line 24 def to_json( = {}) ActiveSupport::JSON.encode({self.class.name.demodulize.underscore.to_sym => instance_values}, ) end |