Class: TimeDoctor::Config
- Inherits:
-
Object
- Object
- TimeDoctor::Config
- Defined in:
- lib/timedoctor/config.rb
Class Method Summary collapse
- .[](key) ⇒ Object
- .[]=(key, value) ⇒ Object
- .config ⇒ Object
- .configure(options = {}, &blk) ⇒ Object
- .inspect ⇒ Object
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #config ⇒ Object
-
#initialize(options) ⇒ Config
constructor
A new instance of Config.
- #inspect ⇒ Object
Constructor Details
#initialize(options) ⇒ Config
Returns a new instance of Config.
44 45 46 |
# File 'lib/timedoctor/config.rb', line 44 def initialize() @config = OpenStruct.new() end |
Class Method Details
.[](key) ⇒ Object
31 32 33 |
# File 'lib/timedoctor/config.rb', line 31 def [](key) config[key] end |
.[]=(key, value) ⇒ Object
35 36 37 |
# File 'lib/timedoctor/config.rb', line 35 def []=(key, value) config[key] = value end |
.config ⇒ Object
27 28 29 |
# File 'lib/timedoctor/config.rb', line 27 def config @config || configure end |
.configure(options = {}, &blk) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/timedoctor/config.rb', line 6 def configure( = {}, &blk) @config = OpenStruct.new() config[:on_token_authorize] ||= lambda do |_data, _conf| end config[:on_token_authorize_error] ||= lambda do |data, _conf| raise UnauthorizedError, data end config[:on_token_refresh] ||= lambda do |_data, _conf| end config[:on_token_refresh_error] ||= lambda do |data, _conf| raise UnauthorizedError, data end instance_exec(config, &blk) if block_given? config end |
.inspect ⇒ Object
39 40 41 |
# File 'lib/timedoctor/config.rb', line 39 def inspect config.to_h end |
Instance Method Details
#[](key) ⇒ Object
52 53 54 |
# File 'lib/timedoctor/config.rb', line 52 def [](key) config[key] || Config[key] end |
#[]=(key, value) ⇒ Object
56 57 58 |
# File 'lib/timedoctor/config.rb', line 56 def []=(key, value) config[key] = value end |
#config ⇒ Object
48 49 50 |
# File 'lib/timedoctor/config.rb', line 48 def config @config ||= OpenStruct.new end |