Class: Deferrer::Item
- Inherits:
-
Object
- Object
- Deferrer::Item
- Defined in:
- lib/deferrer/item.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #==(object) ⇒ Object
-
#initialize(id, class_name, args) ⇒ Item
constructor
A new instance of Item.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(id, class_name, args) ⇒ Item
Returns a new instance of Item.
13 14 15 16 17 |
# File 'lib/deferrer/item.rb', line 13 def initialize(id, class_name, args) @id = id @class_name = class_name @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
6 7 8 |
# File 'lib/deferrer/item.rb', line 6 def args @args end |
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
6 7 8 |
# File 'lib/deferrer/item.rb', line 6 def class_name @class_name end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/deferrer/item.rb', line 6 def id @id end |
Class Method Details
.from_json(json) ⇒ Object
8 9 10 11 |
# File 'lib/deferrer/item.rb', line 8 def self.from_json(json) item = MultiJson.load(json) new(item['id'], item['class'], item['args']) end |
Instance Method Details
#==(object) ⇒ Object
27 28 29 |
# File 'lib/deferrer/item.rb', line 27 def ==(object) object.id == self.id end |
#to_hash ⇒ Object
23 24 25 |
# File 'lib/deferrer/item.rb', line 23 def to_hash { 'id' => id, 'class' => class_name, 'args' => args } end |
#to_json ⇒ Object
19 20 21 |
# File 'lib/deferrer/item.rb', line 19 def to_json MultiJson.dump(to_hash) end |