Class: Hootenanny::Request
- Inherits:
-
Object
- Object
- Hootenanny::Request
- Defined in:
- lib/hootenanny/errors.rb,
lib/hootenanny/request.rb,
lib/hootenanny/request/subscription.rb,
lib/hootenanny/request/publish_notification.rb
Direct Known Subclasses
Defined Under Namespace
Classes: BuildError, PublishNotification, Subscription
Instance Attribute Summary collapse
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
-
.build(options = {}) ⇒ Object
Private: Builds a specific request object based on the options passed in.
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/hootenanny/request.rb', line 7 def type @type end |
Class Method Details
.build(options = {}) ⇒ Object
Private: Builds a specific request object based on the options passed in.
options - A Hash of options representing the request that will be built. The
only option that is required for _this_ method is :type, however
depending on the class that is to be built, it may require other
options. See each class in turn for details.
:type - The type of request that should be built. Currently, valid
opitons are:
* :subscription
Examples:
Hootenanny::Request.build(type: :subscription,
callback: 'http://example.com',)
# => <Hootenanny::Request::Subscription>
Returns an indeterminate type of object based on the :type option Raises Hootenanny::Request::BuildError if there is a problem
31 32 33 34 35 36 37 38 |
# File 'lib/hootenanny/request.rb', line 31 def self.build( = {}) type = .fetch(:type).to_s.camelize klass = "Hootenanny::Request::#{type}".constantize klass.build rescue KeyError => e raise Hootenanny::Request::BuildError.wrap(e) end |