Class: SAXMachine::SAXConfig::CollectionConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/sax-machine/sax_collection_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ CollectionConfig

Returns a new instance of CollectionConfig.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/sax-machine/sax_collection_config.rb', line 7

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/sax-machine/sax_collection_config.rb', line 5

def name
  @name
end

Instance Method Details

#accessorObject



20
21
22
# File 'lib/sax-machine/sax_collection_config.rb', line 20

def accessor
  as
end

#attrs_match?(attrs) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
# File 'lib/sax-machine/sax_collection_config.rb', line 24

def attrs_match?(attrs)
  if @with
    @with == (@with & attrs)
  else
    true
  end
end

#data_classObject



32
33
34
# File 'lib/sax-machine/sax_collection_config.rb', line 32

def data_class
  @class || @name
end