Module: Videojuicer::Configurable

Included in:
OAuth::RequestProxy, Resource, Session
Defined in:
lib/videojuicer/shared/configurable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#local_configObject

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_versionObject

Retrieves the api_version from the configuration options.



94
# File 'lib/videojuicer/shared/configurable.rb', line 94

def api_version; config[:api_version]; end

#configObject

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!(options={})
  self.local_config = options
end

#consumer_keyObject

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_secretObject

Retrieves the consumer_secret from the configuration options.



88
# File 'lib/videojuicer/shared/configurable.rb', line 88

def consumer_secret; config[:consumer_secret]; end

#hostObject

Retrieves the host from the configuration options.



82
# File 'lib/videojuicer/shared/configurable.rb', line 82

def host; config[:host]; end

#portObject

Retrieves the port from the configuration options.



84
# File 'lib/videojuicer/shared/configurable.rb', line 84

def port; config[:port]; end

#protocolObject

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_nameObject

Retrieves the seed name from the configuration options.



98
# File 'lib/videojuicer/shared/configurable.rb', line 98

def seed_name; config[:seed_name]; end

#tokenObject

Retrieves the token from the configuration options.



90
# File 'lib/videojuicer/shared/configurable.rb', line 90

def token; config[:token]; end

#token_secretObject

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_idObject

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