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.



25
26
27
28
29
30
31
32
# File 'lib/simple_ams/options/relations.rb', line 25

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 ? true : false
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)


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

def collection?
  @many
end

#rawObject



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

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

#single?Boolean

Returns:

  • (Boolean)


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

def single?
  !collection?
end