Class: Fragmentary::Subscription
- Inherits:
-
Object
- Object
- Fragmentary::Subscription
- Includes:
- ActiveSupport::Callbacks
- Defined in:
- lib/fragmentary/subscription.rb
Defined Under Namespace
Classes: Proxy
Instance Attribute Summary collapse
-
#record ⇒ Object
Returns the value of attribute record.
-
#subscriber ⇒ Object
readonly
Returns the value of attribute subscriber.
Instance Method Summary collapse
- #after_create(record) ⇒ Object
- #after_destroy(record) ⇒ Object
- #after_update(record) ⇒ Object
-
#initialize(publisher, subscriber) ⇒ Subscription
constructor
A new instance of Subscription.
Constructor Details
#initialize(publisher, subscriber) ⇒ Subscription
Returns a new instance of Subscription.
52 53 54 55 |
# File 'lib/fragmentary/subscription.rb', line 52 def initialize(publisher, subscriber) @subscriber = subscriber Proxy.fetch(publisher.name).register(self) end |
Instance Attribute Details
#record ⇒ Object
Returns the value of attribute record.
50 51 52 |
# File 'lib/fragmentary/subscription.rb', line 50 def record @record end |
#subscriber ⇒ Object (readonly)
Returns the value of attribute subscriber.
49 50 51 |
# File 'lib/fragmentary/subscription.rb', line 49 def subscriber @subscriber end |
Instance Method Details
#after_create(record) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/fragmentary/subscription.rb', line 57 def after_create(record) run_callbacks :after_create do @record = record call_method(:"create_#{record.class.model_name.param_key}_successful", record) end end |
#after_destroy(record) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/fragmentary/subscription.rb', line 68 def after_destroy(record) # An ActiveSupport::Callbacks :after_destroy callback is set on the eigenclass of each individual # subscription in Fragment.set_record_type in order to clean up fragments whose AR records are destroyed. run_callbacks :after_destroy do @record = record call_method(:"destroy_#{record.class.model_name.param_key}_successful", record) end end |
#after_update(record) ⇒ Object
64 65 66 |
# File 'lib/fragmentary/subscription.rb', line 64 def after_update(record) call_method(:"update_#{record.class.model_name.param_key}_successful", record) end |