Module: Videojuicer::Configurable
- Included in:
- OAuth::RequestProxy, Resource, Session
- Defined in:
- lib/videojuicer/shared/configurable.rb
Instance Attribute Summary collapse
-
#local_config ⇒ Object
Returns the value of attribute local_config.
Instance Method Summary collapse
-
#api_version ⇒ Object
Retrieves the api_version from the configuration options.
-
#config ⇒ Object
Returns the shared configuration, which is the current controller scope merged with the local config.
-
#configure!(options = {}) ⇒ Object
Sets the local configuration for this Configurable.
-
#consumer_key ⇒ Object
Retrieves the consumer_key from the configuration options.
-
#consumer_secret ⇒ Object
Retrieves the consumer_secret from the configuration options.
-
#host ⇒ Object
Retrieves the host from the configuration options.
-
#port ⇒ Object
Retrieves the port from the configuration options.
-
#protocol ⇒ Object
Retrieves the protocol from the configuration options.
-
#scope(&block) ⇒ Object
Executes a block of code within the scope of this Configurable’s local configuration.
-
#seed_name ⇒ Object
Retrieves the seed name from the configuration options.
-
#token ⇒ Object
Retrieves the token from the configuration options.
-
#token_secret ⇒ Object
Retrieves the token_secret from the configuration options.
-
#user_id ⇒ Object
Retrieves the user_id from the configuration options.
Instance Attribute Details
#local_config ⇒ Object
Returns the value of attribute local_config.
37 38 39 |
# File 'lib/videojuicer/shared/configurable.rb', line 37 def local_config @local_config end |
Instance Method Details
#api_version ⇒ Object
Retrieves the api_version from the configuration options.
94 |
# File 'lib/videojuicer/shared/configurable.rb', line 94 def api_version; config[:api_version]; end |
#config ⇒ Object
Returns the shared configuration, which is the current controller scope merged with the local config.
48 49 50 |
# File 'lib/videojuicer/shared/configurable.rb', line 48 def config Videojuicer.current_scope.merge(local_config || {}) end |
#configure!(options = {}) ⇒ Object
Sets the local configuration for this Configurable. The local configuration will always be respected regardless of the current controller scope.
42 43 44 |
# File 'lib/videojuicer/shared/configurable.rb', line 42 def configure!(={}) self.local_config = end |
#consumer_key ⇒ Object
Retrieves the consumer_key from the configuration options.
86 |
# File 'lib/videojuicer/shared/configurable.rb', line 86 def consumer_key; config[:consumer_key]; end |
#consumer_secret ⇒ Object
Retrieves the consumer_secret from the configuration options.
88 |
# File 'lib/videojuicer/shared/configurable.rb', line 88 def consumer_secret; config[:consumer_secret]; end |
#host ⇒ Object
Retrieves the host from the configuration options.
82 |
# File 'lib/videojuicer/shared/configurable.rb', line 82 def host; config[:host]; end |
#port ⇒ Object
Retrieves the port from the configuration options.
84 |
# File 'lib/videojuicer/shared/configurable.rb', line 84 def port; config[:port]; end |
#protocol ⇒ Object
Retrieves the protocol from the configuration options.
96 |
# File 'lib/videojuicer/shared/configurable.rb', line 96 def protocol; config[:protocol]; end |
#scope(&block) ⇒ Object
Executes a block of code within the scope of this Configurable’s local configuration.
This is achieved by pushing the local configuration onto the controller’s scope stack, executing the given block and then exiting the scope. During this procedure the local configuration on this object will remain unchanged.
Example: Videojuicer.configure! :bar=>“baz” configurable_a.configure! :foo=>“a” configurable_b.configure! :foo=>“b”
configurable_a.scope do |config|
config[:bar] #=> "baz"
config[:foo] #=> "a"
configurable_b.scope do |config|
config[:foo] #=> "b"
end
config[:foo] #=> "a"
end
74 75 76 77 78 79 |
# File 'lib/videojuicer/shared/configurable.rb', line 74 def scope(&block) Videojuicer.enter_scope local_config block_out = block.call(Videojuicer.current_scope) Videojuicer.exit_scope return block_out end |
#seed_name ⇒ Object
Retrieves the seed name from the configuration options.
98 |
# File 'lib/videojuicer/shared/configurable.rb', line 98 def seed_name; config[:seed_name]; end |
#token ⇒ Object
Retrieves the token from the configuration options.
90 |
# File 'lib/videojuicer/shared/configurable.rb', line 90 def token; config[:token]; end |
#token_secret ⇒ Object
Retrieves the token_secret from the configuration options.
92 |
# File 'lib/videojuicer/shared/configurable.rb', line 92 def token_secret; config[:token_secret]; end |
#user_id ⇒ Object
Retrieves the user_id from the configuration options. Master tokens can be used to authenticate as any user.
100 |
# File 'lib/videojuicer/shared/configurable.rb', line 100 def user_id; config[:user_id]; end |