Class: Comma::DataExtractor
- Defined in:
- lib/comma/extractors.rb
Instance Method Summary collapse
Methods inherited from Extractor
Constructor Details
This class inherits a constructor from Comma::Extractor
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/comma/extractors.rb', line 55 def method_missing(sym, *args, &block) if args.blank? @results << yield_block_with_value( extract_value_from_object(@instance, sym), &block) end args.each do |arg| case arg when Hash arg.each do |k, v| @results << yield_block_with_value( extract_value_from_object( get_association(@instance, sym), k), &block) end when Symbol @results << yield_block_with_value( extract_value_from_object( get_association(@instance, sym), arg), &block) when String @results << yield_block_with_value( extract_value_from_object(@instance, sym), &block) else raise "Unknown data symbol #{arg.inspect}" end end end |
Instance Method Details
#__static_column__(header = nil, &block) ⇒ Object
82 83 84 |
# File 'lib/comma/extractors.rb', line 82 def __static_column__(header = nil, &block) @results << (block ? yield : nil) end |