Sha256: 47c6dbbf174d2caf9ded8a6f11ba25d9cf03f914d39758a62d3684f4fdb2dbbb

Contents?: true

Size: 768 Bytes

Versions: 2

Compression:

Stored size: 768 Bytes

Contents

module SAXMachine
  class SAXConfig
    
    class CollectionConfig
      attr_reader :name
      
      def initialize(name, options)
        @name   = name.to_s
        @class  = options[:class]
        @as     = options[:as].to_s
        
        if options.has_key?(:with)
          @with = options[:with].to_a.map {|(k,v)| [k.to_s, v.to_s] }
        end
      end
      
      def accessor
        as
      end
      
      def attrs_match?(attrs)
        return true unless @with

        @with.all? do |k,v|
          if pair = attrs.assoc(k)
            pair.last == v
          end
        end
      end

      def data_class
        @class || @name
      end      
      
    protected
      
      def as
        @as
      end
      
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lazy-sax-machine-0.1.1 lib/lazy-sax-machine/sax_collection_config.rb
lazy-sax-machine-0.1.0 lib/lazy-sax-machine/sax_collection_config.rb