Module: NitroRails::BroadcastableModel
- Included in:
- Record
- Defined in:
- app/models/nitro_rails/broadcastable_model.rb
Instance Method Summary collapse
-
#action_broadcasts(methods = {}) ⇒ Object
Action Broadcasts.
- #attribute_broadcasts(broadcasts = {}) ⇒ Object
-
#broadcast_affiliations(*affiliations) ⇒ Object
Affiliations.
- #broadcast_on_action(action, *methods) ⇒ Object
-
#broadcast_on_attribute(attribute, *methods) ⇒ Object
Attribute Broadcasts.
- #broadcast_on_create(*methods) ⇒ Object
- #broadcast_on_delete(*methods) ⇒ Object
- #broadcast_on_update(*methods) ⇒ Object
- #collection_tag ⇒ Object
- #skip_attribute_broadcasting(*attributes) ⇒ Object
- #skipped_attributes ⇒ Object
-
#status_attributes(*attributes) ⇒ Object
Status Attributes.
- #template ⇒ Object
-
#type ⇒ Object
Broadcast Identification.
-
#use_default_broadcasts! ⇒ Object
Default broadcasts.
- #use_refresh_broadcasts! ⇒ Object
Instance Method Details
#action_broadcasts(methods = {}) ⇒ Object
Action Broadcasts
20 21 22 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 20 def action_broadcasts(methods = {}) @action_broadcasts ||= methods end |
#attribute_broadcasts(broadcasts = {}) ⇒ Object
62 63 64 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 62 def attribute_broadcasts(broadcasts = {}) @attribute_broadcasts ||= broadcasts end |
#broadcast_affiliations(*affiliations) ⇒ Object
Affiliations
51 52 53 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 51 def broadcast_affiliations(*affiliations) @affiliations ||= affiliations end |
#broadcast_on_action(action, *methods) ⇒ Object
36 37 38 39 40 41 42 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 36 def broadcast_on_action(action, *methods) if action_broadcasts[action].present? action_broadcasts[action].concat(methods) else action_broadcasts[action] = methods end end |
#broadcast_on_attribute(attribute, *methods) ⇒ Object
Attribute Broadcasts
58 59 60 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 58 def broadcast_on_attribute(attribute, *methods) attribute_broadcasts[attribute] = methods end |
#broadcast_on_create(*methods) ⇒ Object
24 25 26 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 24 def broadcast_on_create(*methods) broadcast_on_action(:create, *methods) end |
#broadcast_on_delete(*methods) ⇒ Object
32 33 34 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 32 def broadcast_on_delete(*methods) broadcast_on_action(:delete, *methods) end |
#broadcast_on_update(*methods) ⇒ Object
28 29 30 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 28 def broadcast_on_update(*methods) broadcast_on_action(:update, *methods) end |
#collection_tag ⇒ Object
87 88 89 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 87 def collection_tag type.pluralize end |
#skip_attribute_broadcasting(*attributes) ⇒ Object
70 71 72 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 70 def skip_attribute_broadcasting(*attributes) @skipped_attributes = attributes end |
#skipped_attributes ⇒ Object
66 67 68 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 66 def skipped_attributes @skipped_attributes ||= [] end |
#status_attributes(*attributes) ⇒ Object
Status Attributes
76 77 78 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 76 def status_attributes(*attributes) @status_attributes ||= attributes end |
#template ⇒ Object
44 45 46 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 44 def template new.template end |
#type ⇒ Object
Broadcast Identification
83 84 85 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 83 def type name.underscore end |
#use_default_broadcasts! ⇒ Object
Default broadcasts
6 7 8 9 10 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 6 def use_default_broadcasts! broadcast_on_create :refresh_page, :focus_on_new_resource broadcast_on_update :update_associated_attributes broadcast_on_delete :remove_everywhere, :redirect_to_index end |
#use_refresh_broadcasts! ⇒ Object
12 13 14 15 16 |
# File 'app/models/nitro_rails/broadcastable_model.rb', line 12 def use_refresh_broadcasts! broadcast_on_create :refresh_page broadcast_on_update :refresh_page broadcast_on_delete :refresh_page end |