Class: SAXMachine::SAXConfig::CollectionConfig

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ CollectionConfig

Returns a new instance of CollectionConfig.



6
7
8
9
10
11
# File 'lib/sax-machine/config/sax_collection.rb', line 6

def initialize(name, options)
  @name  = name.to_s
  @class = options[:class]
  @as    = options[:as].to_s
  @with  = options.fetch(:with, {})
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/sax-machine/config/sax_collection.rb', line 4

def name
  @name
end

Instance Method Details

#accessorObject



13
14
15
# File 'lib/sax-machine/config/sax_collection.rb', line 13

def accessor
  as
end

#attrs_match?(attrs) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/sax-machine/config/sax_collection.rb', line 17

def attrs_match?(attrs)
  @with.all? do |key, value|
    value === attrs[key.to_s]
  end
end

#data_classObject



23
24
25
# File 'lib/sax-machine/config/sax_collection.rb', line 23

def data_class
  @class || @name
end