Class: Conduit::Request
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Conduit::Request
- Includes:
- Concerns::Storage
- Defined in:
- app/models/conduit/request.rb
Instance Method Summary collapse
-
#content ⇒ Object
Overriding this method fixes an issue where content isn’t set until after the raw action is instantiated.
-
#perform_request ⇒ Object
Perform the requested action for the specified driver.
-
#subscribers ⇒ Object
Fetch a list of subscribers through the subscriptions association.
-
#subscribers=(args) ⇒ Object
Allow creation of subscriptions through the subscribers virtual attribute.
Instance Method Details
#content ⇒ Object
Overriding this method fixes an issue where content isn’t set until after the raw action is instantiated
34 35 36 |
# File 'app/models/conduit/request.rb', line 34 def content raw.view || super end |
#perform_request ⇒ Object
Perform the requested action for the specified driver
41 42 43 44 45 |
# File 'app/models/conduit/request.rb', line 41 def perform_request if response = raw.perform responses.create(content: response.body) end end |
#subscribers ⇒ Object
Fetch a list of subscribers through the subscriptions association
NOTE: This is usually possible by default with a
has_many :through, but with polymorphic
association it gets more complicated.
68 69 70 |
# File 'app/models/conduit/request.rb', line 68 def subscribers subscriptions.map(&:subscriber) end |
#subscribers=(args) ⇒ Object
Allow creation of subscriptions through the subscribers virtual attribute.
NOTE: This is usually possible by default with a
has_many :through, but with polymorphic
association it gets more complicated.
54 55 56 57 58 59 |
# File 'app/models/conduit/request.rb', line 54 def subscribers=(args) args.map do |arg| next unless arg.class < ActiveRecord::Base subscriptions.build(subscriber: arg) end end |