Class: HatenaFotolife::Configuration
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- HatenaFotolife::Configuration
- Defined in:
- lib/hatena_fotolife/configuration.rb
Constant Summary collapse
- OAUTH_KEYS =
%i(consumer_key consumer_secret access_token access_token_secret)
Class Method Summary collapse
-
.create(config_file) ⇒ HatenaFotolife::Configuration
Create a new configuration.
Instance Method Summary collapse
Class Method Details
.create(config_file) ⇒ HatenaFotolife::Configuration
Create a new configuration.
12 13 14 15 16 |
# File 'lib/hatena_fotolife/configuration.rb', line 12 def self.create(config_file) loaded_config = YAML.load(ERB.new(File.read(config_file)).result) config = new(loaded_config) config.check_valid_or_raise end |
Instance Method Details
#check_valid_or_raise ⇒ Object
18 19 20 21 22 23 |
# File 'lib/hatena_fotolife/configuration.rb', line 18 def check_valid_or_raise unless (lacking_keys = self.send(:lacking_keys)).empty? raise ConfigurationError, "Following keys are not setup. #{lacking_keys.map(&:to_s)}" end self end |