class FunWith::Configurations::TryObject
Public Class Methods
new( config )
click to toggle source
takes a Config
object
# File lib/fun_with/configurations/try_object.rb, line 5 def initialize( config ) @config = config @success = true @leaf = false end
Public Instance Methods
[](method_key)
click to toggle source
# File lib/fun_with/configurations/try_object.rb, line 15 def [] method_key follow_config_method_chain( method_key.to_sym ) end
config_method_chain_result( *keys )
click to toggle source
# File lib/fun_with/configurations/try_object.rb, line 36 def config_method_chain_result( *keys ) keys = keys.flatten if success? keys.each do |k| follow_config_method_chain(k) end end TryResult.new( @config, success? ) end
follow_config_method_chain( method )
click to toggle source
# File lib/fun_with/configurations/try_object.rb, line 19 def follow_config_method_chain( method ) if @success == true if @config.is_a?(Config) && @config.has_key?(method) @config = @config[method] unless @config.is_a?(Config) @leaf = true end elsif @leaf @leaf = false # declare unsuccessful on next call. else @success = false end end self end
method_missing( method, *args )
click to toggle source
# File lib/fun_with/configurations/try_object.rb, line 11 def method_missing( method, *args ) follow_config_method_chain( method ) end
success?()
click to toggle source
# File lib/fun_with/configurations/try_object.rb, line 48 def success? @success end