Module: Conduit::Core::Driver
- Defined in:
- lib/conduit/core/driver.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#action(action_name) ⇒ Object
Set available actions.
-
#actions ⇒ Object
Storage array for required credentials.
-
#credentials ⇒ Object
Storage array for required credentials.
-
#optional_attributes(*args) ⇒ Object
Set optional attributes Useful for specifying overrides and other attributes that MAY be set for every request.
-
#permitted_attributes ⇒ Object
Storage array for permitted attributes.
-
#required_attributes(*args) ⇒ Object
Set required attributes Useful for specifying attributes that MUST be set for every request.
-
#required_credentials(*args) ⇒ Object
Set required credentials.
Class Method Details
.extended(base) ⇒ Object
26 27 28 29 |
# File 'lib/conduit/core/driver.rb', line 26 def self.extended(base) base.instance_variable_set('@_driver_path', File.dirname(caller.first[/^[^:]+/])) end |
Instance Method Details
#action(action_name) ⇒ Object
Set available actions
e.g.
> action :purchase
74 75 76 77 78 |
# File 'lib/conduit/core/driver.rb', line 74 def action(action_name) require File.join(@_driver_path, 'actions', action_name.to_s) require File.join(@_driver_path, 'parsers', action_name.to_s) actions << action_name end |
#actions ⇒ Object
Storage array for required credentials
e.g. Conduit::Driver::Fusion.actions
> [:purchase]
106 107 108 |
# File 'lib/conduit/core/driver.rb', line 106 def actions @actions ||= Set.new end |
#credentials ⇒ Object
Storage array for required credentials
e.g. Conduit::Driver::Fusion.credentials
> [:foo, :bar, :baz]
86 87 88 |
# File 'lib/conduit/core/driver.rb', line 86 def credentials @credentials ||= Set.new end |
#optional_attributes(*args) ⇒ Object
Set optional attributes Useful for specifying overrides and other attributes that MAY be set for every request.
e.g. optional_attributes :quux
> <Set :quux>
63 64 65 66 67 |
# File 'lib/conduit/core/driver.rb', line 63 def optional_attributes(*args) optional_attribute_set.tap do |attrs| attrs.merge(args) end end |
#permitted_attributes ⇒ Object
Storage array for permitted attributes
e.g. Conduit::Driver::Fusion.permitted_attributes
> <Set :bar, :baz, :quuz>
96 97 98 |
# File 'lib/conduit/core/driver.rb', line 96 def permitted_attributes required_attribute_set + optional_attribute_set end |
#required_attributes(*args) ⇒ Object
Set required attributes Useful for specifying attributes that MUST be set for every request.
e.g. required_attributes :foo, :bar, :baz
> <Set :bar, :baz>
48 49 50 51 52 |
# File 'lib/conduit/core/driver.rb', line 48 def required_attributes(*args) required_attribute_set.tap do |attrs| attrs.merge(args) end end |
#required_credentials(*args) ⇒ Object
Set required credentials
e.g.
> required_credentials :foo, :bar, :baz
36 37 38 |
# File 'lib/conduit/core/driver.rb', line 36 def required_credentials(*args) credentials.merge(args) end |