Class: Mapricot::Association

Inherits:
Object
  • Object
show all
Defined in:
lib/mapricot/associations.rb

Overview

Abstract class; used to subclass HasOneAssociation and HasManyAssociation

Direct Known Subclasses

HasManyAssociation, HasOneAssociation

Constant Summary collapse

VALID_TYPES =
[:integer, :time, :xml, :string]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, opts = {}) ⇒ Association

Returns a new instance of Association.



9
10
11
12
13
# File 'lib/mapricot/associations.rb', line 9

def initialize(name, type, opts = {})
  raise "Don't instantiate me" if abstract_class?
  @name, @type, @opts = name, type, opts
  @namespace = nil
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/mapricot/associations.rb', line 6

def name
  @name
end

#namespaceObject

Returns the value of attribute namespace.



7
8
9
# File 'lib/mapricot/associations.rb', line 7

def namespace
  @namespace
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/mapricot/associations.rb', line 6

def type
  @type
end

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/mapricot/associations.rb', line 6

def value
  @value
end

Instance Method Details

#tag_nameObject



15
16
17
# File 'lib/mapricot/associations.rb', line 15

def tag_name
  @opts[:tag_name] || singular_name
end