Class: EOAT::Result::EveType::Row
- Inherits:
-
Object
- Object
- EOAT::Result::EveType::Row
- Defined in:
- lib/eoat/result/eve_type.rb
Overview
Key-values container. All methods generated automatically.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Row
constructor
A new instance of Row.
- #method_missing(meth, *args, &block) ⇒ Object
- #respond_to?(meth) ⇒ Boolean
Constructor Details
#initialize(hash) ⇒ Row
Returns a new instance of Row.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/eoat/result/eve_type.rb', line 173 def initialize(hash) hash.each do |key, value| case value when Hash if value.key? 'row' var_name = value['name'] var_value = RowSet.new(value) else var_name = key var_value = Row.new(value) end self.instance_variable_set("@#{var_name}",var_value) self.class.send( :define_method, var_name, proc { self.instance_variable_get("@#{var_name}") } ) when String, NilClass self.instance_variable_set("@#{key}", value) self.class.send( :define_method, key, proc { self.instance_variable_get("@#{key}") } ) when Array value.each do |element| self.instance_variable_set("@#{element['name']}", RowSet.new(element)) self.class.send( :define_method, element['name'], proc { self.instance_variable_get("@#{element['name']}") } ) end else raise EOAT::Exception::ParseError.new "Unable to parse the the key: #{key}, value: #{value.class}; hash: #{hash}." end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
218 219 220 221 222 223 224 |
# File 'lib/eoat/result/eve_type.rb', line 218 def method_missing(meth, *args, &block) if instance_variable_defined?("@#{meth.to_s}") instance_variable_get("@#{meth.to_s}") else super end end |
Instance Method Details
#respond_to?(meth) ⇒ Boolean
226 227 228 229 230 231 232 |
# File 'lib/eoat/result/eve_type.rb', line 226 def respond_to?(meth) if instance_variable_defined?("@#{meth.to_s}") true else super end end |