Class: TDriver::ParameterHash
- Defined in:
- lib/tdriver/util/parameter/parameter.rb
Overview
ParameterUserAPI
Instance Method Summary collapse
-
#[](key, *default, &block) ⇒ Object
TODO: document me.
-
#[]=(key, value) ⇒ Object
TODO: document me.
-
#apply_template(name) ⇒ Object
TODO: document me.
-
#kind_of?(klass) ⇒ Boolean
for backwards compatibility.
Methods inherited from Hash
#collect_keys, #default_value, #default_values, #delete_keys, #delete_keys!, #if_found, #not_empty, #recursive_merge, #recursive_merge!, #rename_key!, #require_key, #require_keys, #require_one, #strip_dynamic_attributes!, #to_attributes
Instance Method Details
#[](key, *default, &block) ⇒ Object
TODO: document me
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/tdriver/util/parameter/parameter.rb', line 127 def []( key, *default, &block ) $last_parameter = fetch( key ){ if default.empty? raise MobyUtil::ParameterNotFoundError, "Parameter #{ key.inspect } not found" unless block_given? # yield with key if block given yield key else raise ArgumentError, "Only one default value allowed for parameter (#{ default.join(', ') })" unless default.size == 1 #result = default.first #result.kind_of?( Hash ) ? convert_hash( result ) : result convert_hash( default.first ) end } end |
#[]=(key, value) ⇒ Object
TODO: document me
156 157 158 159 160 161 162 |
# File 'lib/tdriver/util/parameter/parameter.rb', line 156 def []=( key, value ) raise MobyUtil::ParameterNotFoundError, 'Parameter key nil is not valid' unless key super key, convert_hash( value ) # value.kind_of?( Hash ) ? convert_hash( value ) : value end |
#apply_template(name) ⇒ Object
TODO: document me
165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/tdriver/util/parameter/parameter.rb', line 165 def apply_template( name ) recursive_merge!( TDriver::Parameter.templates.fetch( name.to_s ){ raise MobyUtil::TemplateNotFoundError, "Template #{ name.inspect } not found" } ) end |
#kind_of?(klass) ⇒ Boolean
for backwards compatibility
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/tdriver/util/parameter/parameter.rb', line 178 def kind_of?( klass ) if klass == MobyUtil::ParameterHash warn_caller '$1:$2 warning: deprecated class MobyUtil::ParameterHash, use TDriver::ParameterHash instead' true else super klass end end |