Module: Nard::Appi::ApiExt::Configuration::ClassMethods

Defined in:
lib/nard/appi/api_ext/configuration.rb

Instance Method Summary collapse

Instance Method Details

#configure {|_self| ... } ⇒ Hash

設定を行うメソッド

Yields:

  • (_self)

Yield Parameters:

Returns:

  • (Hash)


18
19
20
21
# File 'lib/nard/appi/api_ext/configuration.rb', line 18

def configure
  yield( self )
  return options
end

#default_optionsHash

デフォルトの設定

Returns:

  • (Hash)


34
35
36
37
38
39
# File 'lib/nard/appi/api_ext/configuration.rb', line 34

def default_options
  option_keys = self::OPTIONS_KEYS
  option_keys.inject( {} ) do | option, key |
    option.merge!( key => self.const_get( "DEFAULT_#{ key.upcase }") )
  end
end

#optionsHash

設定内容を返すメソッド

Returns:

  • (Hash)


25
26
27
28
29
30
# File 'lib/nard/appi/api_ext/configuration.rb', line 25

def options
  option_keys = self::OPTIONS_KEYS
  option_keys.inject( {} ) do | option, key |
    option.merge!( key => send( key ) )
  end
end

#reset!Hash

設定内容をデフォルトの状態にするメソッド

Returns:

  • (Hash)


43
44
45
46
47
48
49
# File 'lib/nard/appi/api_ext/configuration.rb', line 43

def reset!
  configure do | config |
    default_options.each do | key, value |
      config.send( "#{ key }=", value )
    end
  end
end