Class: NaranyaEcm::Rest::AssociationRelation

Inherits:
Relation
  • Object
show all
Defined in:
lib/naranya_ecm/rest/association_relation.rb

Instance Attribute Summary collapse

Attributes inherited from Relation

#conditions, #elements, #klass

Instance Method Summary collapse

Methods inherited from Relation

#[], #limit, #load, #to_a, #where

Constructor Details

#initialize(given_klass, given_foreign_key_name, given_foreign_key_value) ⇒ AssociationRelation

Returns a new instance of AssociationRelation.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
# File 'lib/naranya_ecm/rest/association_relation.rb', line 8

def initialize(given_klass, given_foreign_key_name, given_foreign_key_value)
  
  raise ArgumentError unless given_foreign_key_name.present?

  @foreign_key_name, @foreign_key_value = given_foreign_key_name, given_foreign_key_value

  super(given_klass, foreign_key_name => foreign_key_value)
  
end

Instance Attribute Details

#foreign_key_nameObject (readonly)

Returns the value of attribute foreign_key_name.



6
7
8
# File 'lib/naranya_ecm/rest/association_relation.rb', line 6

def foreign_key_name
  @foreign_key_name
end

#foreign_key_valueObject (readonly)

Returns the value of attribute foreign_key_value.



6
7
8
# File 'lib/naranya_ecm/rest/association_relation.rb', line 6

def foreign_key_value
  @foreign_key_value
end

Instance Method Details

#fetch_from_serverObject



18
19
20
# File 'lib/naranya_ecm/rest/association_relation.rb', line 18

def fetch_from_server
  foreign_key_value.present? ? super : []
end