class Configurator::Parameter
Constants
- METHOD_NAME_REGEXP
Public Class Methods
new( data = {}, fullname = "" )
click to toggle source
# File lib/aerogel/configurator/parameter.rb, line 7 def initialize( data = {}, fullname = "" ) @data = data @fullname = fullname end
Public Instance Methods
each( ) { |method, value| ... }
click to toggle source
Iterates over parameter group.
# File lib/aerogel/configurator/parameter.rb, line 62 def each( &block ) @data.keys.each do |method| value = send method yield method, value end end
inspect()
click to toggle source
# File lib/aerogel/configurator/parameter.rb, line 56 def inspect @data.inspect end
method_missing(method, *args)
click to toggle source
# File lib/aerogel/configurator/parameter.rb, line 12 def method_missing(method, *args) param_name = method.to_s.match(METHOD_NAME_REGEXP)[1].to_sym force_value = false force_boolean = false # puts "Parameter.method_missing: #{@fullname}.#{method} '(#{param_name}) in #{@data}" if method.to_s =~ /=$/ return @data[param_name] = args.first elsif method.to_s =~ /\!$/ force_value = true elsif method.to_s =~ /\?$/ force_boolean = true end # evaluate param if @data[param_name].is_a?(Hash) force_boolean ? true : Parameter.new( @data[param_name], "#{@fullname}.#{param_name}" ) elsif @data[param_name].nil? raise ArgumentError.new "Undefined parameter: #{@fullname}.#{param_name}" if force_value force_boolean ? false : Undefined.new( @data, [param_name], "#{@fullname}.#{param_name}" ) elsif @data[param_name].is_a? Proc force_boolean ? !!@data[param_name].call : @data[param_name].call else # it's a leaf force_boolean ? !!@data[param_name] : @data[param_name] end end
raw()
click to toggle source
# File lib/aerogel/configurator/parameter.rb, line 48 def raw @data end
respond_to?( method, include_private = false )
click to toggle source
Calls superclass method
# File lib/aerogel/configurator/parameter.rb, line 39 def respond_to?( method, include_private = false ) super || respond_to_missing?( method, include_private ) end
respond_to_missing?( method, include_private = false )
click to toggle source
any valid identifier ending with ‘=’, ‘!’ or ‘?’ is a valid method
Calls superclass method
# File lib/aerogel/configurator/parameter.rb, line 44 def respond_to_missing?( method, include_private = false ) super || (method.to_s =~ METHOD_NAME_REGEXP ) || true end
to_hash()
click to toggle source
# File lib/aerogel/configurator/parameter.rb, line 52 def to_hash @data end