Class: FakeSNS::Database
- Inherits:
-
Object
- Object
- FakeSNS::Database
- Defined in:
- lib/fake_sns/database.rb
Instance Attribute Summary collapse
-
#database_filename ⇒ Object
readonly
Returns the value of attribute database_filename.
Instance Method Summary collapse
- #each_deliverable_message ⇒ Object
-
#initialize(database_filename) ⇒ Database
constructor
A new instance of Database.
- #messages ⇒ Object
- #perform(action, params) ⇒ Object
- #replace(data) ⇒ Object
- #reset ⇒ Object
- #subscriptions ⇒ Object
- #to_yaml ⇒ Object
- #topics ⇒ Object
- #transaction ⇒ Object
Constructor Details
#initialize(database_filename) ⇒ Database
Returns a new instance of Database.
9 10 11 |
# File 'lib/fake_sns/database.rb', line 9 def initialize(database_filename) @database_filename = database_filename || File.join(Dir.home, ".fake_sns.yml") end |
Instance Attribute Details
#database_filename ⇒ Object (readonly)
Returns the value of attribute database_filename.
7 8 9 |
# File 'lib/fake_sns/database.rb', line 7 def database_filename @database_filename end |
Instance Method Details
#each_deliverable_message ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/fake_sns/database.rb', line 51 def topics.each do |topic| subscriptions.each do |subscription| .each do || if .topic_arn == topic.arn yield subscription, end end end end end |
#messages ⇒ Object
27 28 29 |
# File 'lib/fake_sns/database.rb', line 27 def @messages ||= MessageCollection.new(store) end |
#perform(action, params) ⇒ Object
13 14 15 16 17 |
# File 'lib/fake_sns/database.rb', line 13 def perform(action, params) action_instance = action_provider(action).new(self, params) action_instance.call Response.new(action_instance) end |
#replace(data) ⇒ Object
43 44 45 |
# File 'lib/fake_sns/database.rb', line 43 def replace(data) store.replace(data) end |
#reset ⇒ Object
31 32 33 34 35 |
# File 'lib/fake_sns/database.rb', line 31 def reset topics.reset subscriptions.reset .reset end |
#subscriptions ⇒ Object
23 24 25 |
# File 'lib/fake_sns/database.rb', line 23 def subscriptions @subscriptions ||= SubscriptionCollection.new(store) end |
#to_yaml ⇒ Object
47 48 49 |
# File 'lib/fake_sns/database.rb', line 47 def to_yaml store.to_yaml end |
#topics ⇒ Object
19 20 21 |
# File 'lib/fake_sns/database.rb', line 19 def topics @topics ||= TopicCollection.new(store) end |
#transaction ⇒ Object
37 38 39 40 41 |
# File 'lib/fake_sns/database.rb', line 37 def transaction store.transaction do yield end end |