Class: Mapricot::Association
- Inherits:
-
Object
- Object
- Mapricot::Association
- Defined in:
- lib/mapricot/associations.rb
Overview
Abstract class; used to subclass HasOneAssociation and HasManyAssociation
Direct Known Subclasses
Constant Summary collapse
- VALID_TYPES =
[:integer, :time, :xml, :string]
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name, type, opts = {}) ⇒ Association
constructor
A new instance of Association.
- #tag_name ⇒ Object
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
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/mapricot/associations.rb', line 6 def name @name end |
#namespace ⇒ Object
Returns the value of attribute namespace.
7 8 9 |
# File 'lib/mapricot/associations.rb', line 7 def namespace @namespace end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/mapricot/associations.rb', line 6 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
6 7 8 |
# File 'lib/mapricot/associations.rb', line 6 def value @value end |
Instance Method Details
#tag_name ⇒ Object
15 16 17 |
# File 'lib/mapricot/associations.rb', line 15 def tag_name @opts[:tag_name] || singular_name end |