Class: Crocoduck::Entry
- Inherits:
-
Object
- Object
- Crocoduck::Entry
- Defined in:
- lib/crocoduck/entry.rb
Instance Attribute Summary collapse
-
#entry ⇒ Object
writeonly
Sets the attribute entry.
-
#entry_id ⇒ Object
Returns the value of attribute entry_id.
-
#store ⇒ Object
writeonly
Sets the attribute store.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Rather than access “Crocoduck::Entry.entry“ directly, one can do the following:.
-
#close ⇒ Object
Call this method on your entries to have them close their own store object.
-
#initialize(entry_id) ⇒ Entry
constructor
A new instance of Entry.
-
#schedule(worker = Job) ⇒ Object
A quick way to start work on an Entry is to do something like the following.
- #setup? ⇒ Boolean
-
#update(field, value) ⇒ Object
This hasn’t been field tested yet, but “update“ should be a convienance method to manipulate a field on the entry document stored here.
Constructor Details
#initialize(entry_id) ⇒ Entry
Returns a new instance of Entry.
12 13 14 |
# File 'lib/crocoduck/entry.rb', line 12 def initialize(entry_id) @entry_id = entry_id end |
Instance Attribute Details
#entry=(value) ⇒ Object
Sets the attribute entry
10 11 12 |
# File 'lib/crocoduck/entry.rb', line 10 def entry=(value) @entry = value end |
#entry_id ⇒ Object
Returns the value of attribute entry_id.
10 11 12 |
# File 'lib/crocoduck/entry.rb', line 10 def entry_id @entry_id end |
#store=(value) ⇒ Object
Sets the attribute store
10 11 12 |
# File 'lib/crocoduck/entry.rb', line 10 def store=(value) @store = value end |
Instance Method Details
#[](key) ⇒ Object
Rather than access “Crocoduck::Entry.entry“ directly, one can do the following:
:001 > e = Crocoduck::Entry.new(50039)
=> #<Crocoduck::Entry:0x101611938 @entry_id=50039>
:002 > e["url"]
=> "/apple/news/2011/04/this-is-not-a-real-article.ars"
31 32 33 34 35 36 37 |
# File 'lib/crocoduck/entry.rb', line 31 def [](key) if entry.has_key? key entry[key] else nil end end |
#close ⇒ Object
Call this method on your entries to have them close their own store object.
50 51 52 |
# File 'lib/crocoduck/entry.rb', line 50 def close store.close end |
#schedule(worker = Job) ⇒ Object
A quick way to start work on an Entry is to do something like the following
>>> e = Entry.new(53029).schedule(ShortUrlJob)
20 21 22 |
# File 'lib/crocoduck/entry.rb', line 20 def schedule(worker = Job) Resque.enqueue worker, entry_id end |
#setup? ⇒ Boolean
54 55 56 |
# File 'lib/crocoduck/entry.rb', line 54 def setup? store.setup? && !entry.nil? end |
#update(field, value) ⇒ Object
This hasn’t been field tested yet, but “update“ should be a convienance method to manipulate a field on the entry document stored here. If a job needed to store results or data on a different document, she could use the “Crocoduck::Store.update“ method directly.
44 45 46 |
# File 'lib/crocoduck/entry.rb', line 44 def update(field, value) store.update entry_id, field, value end |