Sha256: 9d21d2c26ff449547e392728f73c66764e59817c3216a8a06dcb828528442ec5

Contents?: true

Size: 782 Bytes

Versions: 8

Compression:

Stored size: 782 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)
          # for faster comparisons later
          @with = options[:with].to_a.flatten.collect {|o| o.to_s}
        else
          @with = nil
        end
      end
      
      def accessor
        as
      end
      
      def attrs_match?(attrs)
        if @with
          @with == (@with & attrs)
        else
          true
        end
      end

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

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
sax-machine-0.2.0.rc1 lib/sax-machine/sax_collection_config.rb
sax-machine-0.1.0 lib/sax-machine/sax_collection_config.rb
sax-machine-0.0.20 lib/sax-machine/sax_collection_config.rb
sax-machine-0.0.16 lib/sax-machine/sax_collection_config.rb
sax-machine-nokogiri-1.4.4-safe-0.0.15 lib/sax-machine/sax_collection_config.rb
orend-sax-machine-0.0.15 lib/sax-machine/sax_collection_config.rb
orend-sax-machine-0.0.14 lib/sax-machine/sax_collection_config.rb
sax-machine-0.0.15 lib/sax-machine/sax_collection_config.rb