Class: JSONAPI::Association

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonapi/association.rb

Direct Known Subclasses

HasMany, HasOne

Defined Under Namespace

Classes: HasMany, HasOne

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Association

Returns a new instance of Association.



5
6
7
8
9
10
11
# File 'lib/jsonapi/association.rb', line 5

def initialize(name, options={})
  @name          = name.to_s
  @options       = options
  @key           = options[:key] ? options[:key].to_sym : nil
  @primary_key   = options.fetch(:primary_key, 'id').to_sym
  @acts_as_set   = options.fetch(:acts_as_set, false) == true
end

Instance Attribute Details

#acts_as_setObject (readonly)

Returns the value of attribute acts_as_set.



3
4
5
# File 'lib/jsonapi/association.rb', line 3

def acts_as_set
  @acts_as_set
end

#class_nameObject (readonly)

Returns the value of attribute class_name.



3
4
5
# File 'lib/jsonapi/association.rb', line 3

def class_name
  @class_name
end

#keyObject (readonly)

Returns the value of attribute key.



3
4
5
# File 'lib/jsonapi/association.rb', line 3

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/jsonapi/association.rb', line 3

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/jsonapi/association.rb', line 3

def options
  @options
end

#primary_keyObject (readonly)

Returns the value of attribute primary_key.



3
4
5
# File 'lib/jsonapi/association.rb', line 3

def primary_key
  @primary_key
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/jsonapi/association.rb', line 3

def type
  @type
end