Class: MediaMonster::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/media_monster/model.rb

Direct Known Subclasses

Job, Sequence, Task

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/media_monster/model.rb', line 5

def id
  @id
end

#statusObject

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(options={})
  {self.class.name.demodulize.underscore.to_sym => as_json_without_class_name(options)}
end

#to_json(options = {}) ⇒ Object



24
25
26
# File 'lib/media_monster/model.rb', line 24

def to_json(options = {})
  ActiveSupport::JSON.encode({self.class.name.demodulize.underscore.to_sym => instance_values}, options)
end