Class: SimpleAMS::Options::Relations::Relation
- Inherits:
-
Object
- Object
- SimpleAMS::Options::Relations::Relation
- Defined in:
- lib/simple_ams/options/relations.rb
Instance Attribute Summary collapse
-
#embedded ⇒ Object
readonly
Returns the value of attribute embedded.
-
#name ⇒ Object
(also: #relation)
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #collection? ⇒ Boolean
-
#initialize(type, name, options = {}, embedded) ⇒ Relation
constructor
A new instance of Relation.
- #raw ⇒ Object
- #single? ⇒ Boolean
Constructor Details
#initialize(type, name, options = {}, embedded) ⇒ Relation
Returns a new instance of Relation.
26 27 28 29 30 31 32 33 |
# File 'lib/simple_ams/options/relations.rb', line 26 def initialize(type, name, = {}, ) @type = type.to_sym @name = name.is_a?(String) ? name.to_sym : name @options = @embedded = @many = type == :has_many end |
Instance Attribute Details
#embedded ⇒ Object (readonly)
Returns the value of attribute embedded.
24 25 26 |
# File 'lib/simple_ams/options/relations.rb', line 24 def @embedded end |
#name ⇒ Object Also known as: relation
Returns the value of attribute name.
24 25 26 |
# File 'lib/simple_ams/options/relations.rb', line 24 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
24 25 26 |
# File 'lib/simple_ams/options/relations.rb', line 24 def @options end |
#type ⇒ Object
Returns the value of attribute type.
24 25 26 |
# File 'lib/simple_ams/options/relations.rb', line 24 def type @type end |
Instance Method Details
#collection? ⇒ Boolean
41 42 43 |
# File 'lib/simple_ams/options/relations.rb', line 41 def collection? @many end |
#raw ⇒ Object
37 38 39 |
# File 'lib/simple_ams/options/relations.rb', line 37 def raw [type, name, , ] end |
#single? ⇒ Boolean
45 46 47 |
# File 'lib/simple_ams/options/relations.rb', line 45 def single? !collection? end |