Module: PlatonicConfig
- Defined in:
- lib/platonic_config/version.rb,
lib/platonic_config.rb
Overview
Placeholder module for versioning
Defined Under Namespace
Modules: ClassMethods
Constant Summary
- VERSION =
Version of the module
"0.1.1"
Class Method Summary (collapse)
-
+ (Object) included(base)
Set up configuration methodss on the base class.
Instance Method Summary (collapse)
-
- (Object) configure {|_self| ... }
(also: #config)
convenience method to allow for block level configuration.
-
- (Object) instance_options
return just the options set on the instance.
-
- (Object) method_missing(sym, *args, &block)
Allow calls directly on the object to configuration keys Ex: define_options :foo => bar instance.foo.
-
- (Object) options
Give the options defined on the instance merged with the class-level defaults.
-
- (Object) reset_defaults
Reset all config values set on the instance.
-
- (Boolean) respond_to?(sym)
Let respond_to? answer for symbols defined in the options.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(sym, *args, &block)
Allow calls directly on the object to configuration keys Ex: define_options :foo => bar instance.foo
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/platonic_config.rb', line 31 def method_missing(sym,*args,&block) if self.class..has_key? sym if args.length == 1 [sym] = args[0] end [sym] else super end end |
Class Method Details
+ (Object) included(base)
Set up configuration methodss on the base class
24 25 26 |
# File 'lib/platonic_config.rb', line 24 def self.included(base) base.extend ClassMethods end |
Instance Method Details
- (Object) configure {|_self| ... } Also known as: config
convenience method to allow for block level configuration
17 18 19 20 |
# File 'lib/platonic_config.rb', line 17 def configure yield self self end |
- (Object) instance_options
return just the options set on the instance
12 13 14 |
# File 'lib/platonic_config.rb', line 12 def @options ||= {} end |
- (Object) options
Give the options defined on the instance merged with the class-level defaults
7 8 9 |
# File 'lib/platonic_config.rb', line 7 def self.class..merge end |
- (Object) reset_defaults
Reset all config values set on the instance
52 53 54 |
# File 'lib/platonic_config.rb', line 52 def reset_defaults @options = {} end |
- (Boolean) respond_to?(sym)
Let respond_to? answer for symbols defined in the options
43 44 45 46 47 48 49 |
# File 'lib/platonic_config.rb', line 43 def respond_to?(sym) if self.class..has_key? sym true else super end end |