Module: HeyYou::Config::Configurable

Included in:
HeyYou::Config, DataSource, Email, Push
Defined in:
lib/hey_you/config/conigurable.rb

Defined Under Namespace

Classes: AlreadyConfiguredError, RequiredConfigsNotPassed

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(klass) ⇒ Object



7
8
9
10
11
# File 'lib/hey_you/config/conigurable.rb', line 7

def self.extended klass
  klass.class_eval do
    include Singleton
  end
end

Instance Method Details

#configObject



19
20
21
# File 'lib/hey_you/config/conigurable.rb', line 19

def config
  @config ||= self.instance
end

#configure(&block) ⇒ Object



13
14
15
16
17
# File 'lib/hey_you/config/conigurable.rb', line 13

def configure(&block)
  @configured ? raise(AlreadyConfiguredError, 'You already configure HeyYou') : instance_eval(&block)
  @configured = true
  instance.validate_config if instance.respond_to?(:validate_config)
end