Class: KNSEmailEndpoint::Storage::AbstractStorage
- Inherits:
-
Object
- Object
- KNSEmailEndpoint::Storage::AbstractStorage
- Defined in:
- lib/kns_email_endpoint/storage/abstract_storage.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#retry_count ⇒ Object
Returns the value of attribute retry_count.
-
#state ⇒ Object
Returns the value of attribute state.
-
#unique_id ⇒ Object
readonly
Returns the value of attribute unique_id.
Instance Method Summary collapse
-
#create(opts = {}) ⇒ Object
create should call set_vars and save! if successful and return true otherwise, it should raise an exception.
-
#delete ⇒ Object
delete should return either true if successful, or false if unsuccessful delete should also call reset_storage if successful.
-
#find(unique_id) ⇒ Object
find should return self if a record is found after calling set_vars it should return nil if not found and call reset_storage.
- #find_or_create(opts = {}) ⇒ Object
-
#initialize(*args) ⇒ AbstractStorage
constructor
A new instance of AbstractStorage.
- #to_h ⇒ Object
Constructor Details
#initialize(*args) ⇒ AbstractStorage
Returns a new instance of AbstractStorage.
6 7 8 9 |
# File 'lib/kns_email_endpoint/storage/abstract_storage.rb', line 6 def initialize(*args) reset_storage end |
Instance Attribute Details
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
4 5 6 |
# File 'lib/kns_email_endpoint/storage/abstract_storage.rb', line 4 def @message_id end |
#retry_count ⇒ Object
Returns the value of attribute retry_count.
4 5 6 |
# File 'lib/kns_email_endpoint/storage/abstract_storage.rb', line 4 def retry_count @retry_count end |
#state ⇒ Object
Returns the value of attribute state.
4 5 6 |
# File 'lib/kns_email_endpoint/storage/abstract_storage.rb', line 4 def state @state end |
#unique_id ⇒ Object (readonly)
Returns the value of attribute unique_id.
4 5 6 |
# File 'lib/kns_email_endpoint/storage/abstract_storage.rb', line 4 def unique_id @unique_id end |
Instance Method Details
#create(opts = {}) ⇒ Object
create should call set_vars and save! if successful and return true otherwise, it should raise an exception
20 21 22 23 |
# File 'lib/kns_email_endpoint/storage/abstract_storage.rb', line 20 def create(opts={}) return false #override me end |
#delete ⇒ Object
delete should return either true if successful, or false if unsuccessful delete should also call reset_storage if successful
13 14 15 16 |
# File 'lib/kns_email_endpoint/storage/abstract_storage.rb', line 13 def delete return false # override me end |
#find(unique_id) ⇒ Object
find should return self if a record is found after calling set_vars it should return nil if not found and call reset_storage
27 28 29 |
# File 'lib/kns_email_endpoint/storage/abstract_storage.rb', line 27 def find(unique_id) return nil #override me end |
#find_or_create(opts = {}) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/kns_email_endpoint/storage/abstract_storage.rb', line 53 def find_or_create(opts={}) unless opts[:unique_id] && opts[:message_id] raise "Must provide at least a unique_id and message_id" end s = find(opts[:unique_id]) return s if s return create(opts) ? self : nil end |
#to_h ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/kns_email_endpoint/storage/abstract_storage.rb', line 43 def to_h return {} unless @unique_id return { :unique_id => @unique_id, :message_id => @message_id, :retry_count => @retry_count, :state => @state } end |