Sha256: baa41414a2e1bc7f3a8544508a78d518c5cb7e25b99fb88067ebc489c716c0b7
Contents?: true
Size: 654 Bytes
Versions: 6
Compression:
Stored size: 654 Bytes
Contents
module ModelXML class BlockParser class << self def parse &block raise "block required" unless block_given? parser = self.new parser.instance_eval &block parser.field_set end end attr_reader :field_set def initialize @field_set = [] end def field *args # if the method is called without arguments, add it as a member of the field set if args.map(&:class) == [Symbol] @field_set << args[0] # otherwise add it as an array else @field_set << args end end def method_missing *args field *args end end end
Version data entries
6 entries across 6 versions & 1 rubygems