Class: Flapjack::Gateways::JSONAPI::Data::JoinDescriptor

Inherits:
Object
  • Object
show all
Defined in:
lib/flapjack/gateways/jsonapi/data/join_descriptor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ JoinDescriptor

Returns a new instance of JoinDescriptor.



16
17
18
19
20
21
22
# File 'lib/flapjack/gateways/jsonapi/data/join_descriptor.rb', line 16

def initialize(opts = {})
  @association_data = nil
  %w{post get patch delete number link includable type klass callback_classes descriptions}.each do |a|
    instance_variable_set("@#{a}", opts[a.to_sym])
  end
  @callback_classes ||= []
end

Instance Attribute Details

#association_dataObject

Returns the value of attribute association_data.



14
15
16
# File 'lib/flapjack/gateways/jsonapi/data/join_descriptor.rb', line 14

def association_data
  @association_data
end

#deleteObject (readonly)

Returns the value of attribute delete.



13
14
15
# File 'lib/flapjack/gateways/jsonapi/data/join_descriptor.rb', line 13

def delete
  @delete
end

#descriptionsObject (readonly)

Returns the value of attribute descriptions.



13
14
15
# File 'lib/flapjack/gateways/jsonapi/data/join_descriptor.rb', line 13

def descriptions
  @descriptions
end

#getObject (readonly)

Returns the value of attribute get.



13
14
15
# File 'lib/flapjack/gateways/jsonapi/data/join_descriptor.rb', line 13

def get
  @get
end

#includableObject (readonly)

Returns the value of attribute includable.



13
14
15
# File 'lib/flapjack/gateways/jsonapi/data/join_descriptor.rb', line 13

def includable
  @includable
end

#klassObject (readonly)

Returns the value of attribute klass.



13
14
15
# File 'lib/flapjack/gateways/jsonapi/data/join_descriptor.rb', line 13

def klass
  @klass
end

Returns the value of attribute link.



13
14
15
# File 'lib/flapjack/gateways/jsonapi/data/join_descriptor.rb', line 13

def link
  @link
end

#numberObject (readonly)

Returns the value of attribute number.



13
14
15
# File 'lib/flapjack/gateways/jsonapi/data/join_descriptor.rb', line 13

def number
  @number
end

#patchObject (readonly)

Returns the value of attribute patch.



13
14
15
# File 'lib/flapjack/gateways/jsonapi/data/join_descriptor.rb', line 13

def patch
  @patch
end

#postObject (readonly)

Returns the value of attribute post.



13
14
15
# File 'lib/flapjack/gateways/jsonapi/data/join_descriptor.rb', line 13

def post
  @post
end

Instance Method Details

#data_klassObject



33
34
35
# File 'lib/flapjack/gateways/jsonapi/data/join_descriptor.rb', line 33

def data_klass
  @association_data.nil? ? @klass : @association_data.data_klass
end

#lock_klassesObject



24
25
26
27
28
29
30
31
# File 'lib/flapjack/gateways/jsonapi/data/join_descriptor.rb', line 24

def lock_klasses
  if @association_data.nil?
    [@klass] | @callback_classes
  else
    [@association_data.data_klass] |
      @association_data.related_klasses | @callback_classes
  end
end

#typeObject



37
38
39
# File 'lib/flapjack/gateways/jsonapi/data/join_descriptor.rb', line 37

def type
  @association_data.nil? ? @type : data_klass.short_model_name.singular
end