Class: Smartfm::Config
- Inherits:
-
Object
- Object
- Smartfm::Config
- Includes:
- Singleton
- Defined in:
- lib/smartfm/core/config.rb
Constant Summary collapse
- ATTRIBUTES =
[ :protocol, :host, :port, :api_protocol, :api_host, :api_port, :api_key, :timeout, :oauth_consumer_key, :oauth_consumer_secret, :oauth_http_method, :oauth_scheme, :user_agent, :application_name, :application_version, :application_url ]
Class Method Summary collapse
- .init {|conf| ... } ⇒ Object
- .method_missing(method, *args) ⇒ Object
-
.timeout ⇒ Object
hack: Object.timeout is already defined..
Instance Method Summary collapse
Class Method Details
.init {|conf| ... } ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/smartfm/core/config.rb', line 10 def self.init(&block) conf = Smartfm::Config.instance { :protocol => 'http', :host => 'smart.fm', :port => 80, :api_protocol => 'http', :api_host => 'api.smart.fm', :api_port => 80, :api_key => '', :timeout => 30, :oauth_consumer_key => '', :oauth_consumer_secret => '', :oauth_http_method => :post, :oauth_scheme => :header, :user_agent => 'default', :application_name => 'smart.fm gem', :application_version => Smartfm::Version.to_version, :application_url => 'http://github.com/nov/smartfm' }.each do |key, value| conf.send("#{key}=", value) end yield conf if block_given? conf end |
.method_missing(method, *args) ⇒ Object
48 49 50 |
# File 'lib/smartfm/core/config.rb', line 48 def self.method_missing(method, *args) Smartfm::Config.instance.send(method, *args) end |
.timeout ⇒ Object
hack: Object.timeout is already defined..
44 45 46 |
# File 'lib/smartfm/core/config.rb', line 44 def self.timeout instance.timeout end |
Instance Method Details
#api_base_url ⇒ Object
38 39 40 41 |
# File 'lib/smartfm/core/config.rb', line 38 def api_base_url port = self.api_port==80 ? nil : ":#{self.api_port}" "#{self.api_protocol}://#{self.api_host}#{port}" end |
#base_url ⇒ Object
33 34 35 36 |
# File 'lib/smartfm/core/config.rb', line 33 def base_url port = self.port==80 ? nil : ":#{self.port}" "#{self.protocol}://#{self.host}#{port}" end |