Class: AdjustableSchema::Relationship::Role

Inherits:
ApplicationRecord show all
Defined in:
app/models/adjustable_schema/relationship/role.rb

Overview

Relationship roles

‘AdjustableSchema::Relationship::Role` serves to distinguish between several associations of the same pair of models.

Class Method Summary collapse

Class Method Details

.[](*names, **scopes) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'app/models/adjustable_schema/relationship/role.rb', line 27

def [] *names, **scopes
	if scopes.any?
		with_relationships { self[**scopes] }
				.distinct
	else
		all
	end
			.scoping { names.any? ? super(*names) : all }
end

.with_relationshipsObject



21
22
23
24
# File 'app/models/adjustable_schema/relationship/role.rb', line 21

def self.with_relationships(&)
	joins(:relationships)
			.merge Relationship.instance_eval(&)
end