Class: Flickr::Config
- Inherits:
-
Object
- Object
- Flickr::Config
- Defined in:
- lib/flickr.rb
Overview
This class supports external configuration
Constant Summary collapse
- @@configuration =
Contains whole configuration for flickr API
{}
- @@parsed =
Is true if configuration has been parsed
false
Class Method Summary collapse
-
.get ⇒ Object
Returns configuration Hash.
-
.load_from_file(file) ⇒ Object
parses file and prepare @@configuration for access from outside to fetch configuration hash.
-
.parse_in_rails_env! ⇒ Object
Excludes specific configuration for choosed environment in Rails.
-
.parsed? ⇒ Boolean
Returns true if configuration has been parsed.
Class Method Details
.get ⇒ Object
Returns configuration Hash
270 271 272 |
# File 'lib/flickr.rb', line 270 def self.get @@configuration end |
.load_from_file(file) ⇒ Object
parses file and prepare @@configuration for access from outside to fetch configuration hash
257 258 259 260 261 262 |
# File 'lib/flickr.rb', line 257 def self.load_from_file file return false unless File.exist?(file) @@configuration = YAML.load(ERB.new(File.read(file)).result) @@parsed = true parse_in_rails_env! end |
.parse_in_rails_env! ⇒ Object
Excludes specific configuration for choosed environment in Rails
265 266 267 |
# File 'lib/flickr.rb', line 265 def self.parse_in_rails_env! @@configuration = @@configuration[RAILS_ENV].symbolize_keys if defined? RAILS_ENV and @@configuration.has_key? RAILS_ENV end |
.parsed? ⇒ Boolean
Returns true if configuration has been parsed
275 276 277 |
# File 'lib/flickr.rb', line 275 def self.parsed? @@parsed end |