Module: Configuru::ConfigMethods
- Defined in:
- lib/configuru/config_methods.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #configure(options = {}) {|_self| ... } ⇒ Object
- #is_locked ⇒ Object
-
#lock(flag = true) ⇒ Object
Instance methods.
- #options_source=(value) ⇒ Object
Class Method Details
.included(base) ⇒ Object
5 6 7 |
# File 'lib/configuru/config_methods.rb', line 5 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#configure(options = {}) {|_self| ... } ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/configuru/config_methods.rb', line 85 def configure(={}) Hash().each_pair do |name,value| if name.to_sym == :options_source self. = value else send("#{name.to_s}=",value) end end yield self if block_given? self end |
#is_locked ⇒ Object
80 81 82 83 |
# File 'lib/configuru/config_methods.rb', line 80 def is_locked @locked = false unless instance_variable_defined?(:@locked) @locked end |
#lock(flag = true) ⇒ Object
Instance methods
77 78 79 |
# File 'lib/configuru/config_methods.rb', line 77 def lock(flag=true) @locked = flag end |
#options_source=(value) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/configuru/config_methods.rb', line 96 def (value) = case value when Hash, Array then value when IO, StringIO, Tempfile then YAML.load(value) when String, Pathname output = {} File.open(value,"r") { |f| output = YAML.load(f) } output else raise ArgumentError.new("Wrong argument class for options_source: #{value.class}") end if .is_a? Array .each { |elem| self.=elem } else configure() end end |