Module: RubySmart::SimpleLogger::Extensions::Scene::ClassMethods
- Defined in:
- lib/ruby_smart/simple_logger/extensions/scene.rb
Instance Method Summary collapse
-
#scene(key, opts = {}, &block) ⇒ Boolean
registers a new scene by provided key & options also defines this method by provided block.
-
#scene?(key) ⇒ Boolean
returns true, if provided key is a registered scene option.
-
#scenes ⇒ Hash
returns all registered scene default options.
-
#scenes=(scenes) ⇒ Object
sets scene options.
Instance Method Details
permalink #scene(key, opts = {}, &block) ⇒ Boolean
registers a new scene by provided key & options also defines this method by provided block
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ruby_smart/simple_logger/extensions/scene.rb', line 49 def scene(key, opts = {}, &block) # protect overwrite existing methods # but allow all severities (levels) return false if instance_methods.include?(key) && !self::LEVEL.key?(key) # register scene default options self.scenes[key] = opts # define (or overwrite) this method, if a block was provided define_method(key, &block) if block_given? # returns success result true end |
permalink #scene?(key) ⇒ Boolean
returns true, if provided key is a registered scene option
33 34 35 |
# File 'lib/ruby_smart/simple_logger/extensions/scene.rb', line 33 def scene?(key) scenes.key?(key) end |
permalink #scenes ⇒ Hash
returns all registered scene default options
20 21 22 |
# File 'lib/ruby_smart/simple_logger/extensions/scene.rb', line 20 def scenes class_variable_get('@@scenes') end |
permalink #scenes=(scenes) ⇒ Object
sets scene options
26 27 28 |
# File 'lib/ruby_smart/simple_logger/extensions/scene.rb', line 26 def scenes=(scenes) class_variable_set('@@scenes', scenes) end |