Class: SimpleAMS::Options::Relations::Relation

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_ams/options/relations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {}, embedded)
  @type = type.to_sym
  @name = name.is_a?(String) ? name.to_sym : name
  @options = options
  @embedded = embedded

  @many = type == :has_many
end

Instance Attribute Details

#embeddedObject (readonly)

Returns the value of attribute embedded.



24
25
26
# File 'lib/simple_ams/options/relations.rb', line 24

def embedded
  @embedded
end

#nameObject 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

#optionsObject

Returns the value of attribute options.



24
25
26
# File 'lib/simple_ams/options/relations.rb', line 24

def options
  @options
end

#typeObject

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

Returns:

  • (Boolean)


41
42
43
# File 'lib/simple_ams/options/relations.rb', line 41

def collection?
  @many
end

#rawObject



37
38
39
# File 'lib/simple_ams/options/relations.rb', line 37

def raw
  [type, name, options, embedded]
end

#single?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/simple_ams/options/relations.rb', line 45

def single?
  !collection?
end