Class: AdjustableSchema::ActiveRecord::Association
- Inherits:
-
Struct
- Object
- Struct
- AdjustableSchema::ActiveRecord::Association
show all
- Extended by:
- Memery
- Includes:
- Memery
- Defined in:
- lib/adjustable_schema/active_record/association.rb,
lib/adjustable_schema/active_record/association/naming.rb
Overview
Defined Under Namespace
Modules: Hierarchy, Referenced, Roleless, Scopes
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Association.
28
29
30
31
32
33
34
|
# File 'lib/adjustable_schema/active_record/association.rb', line 28
def initialize(...)
super
extend Roleless if roleless?
extend Hierarchy if hierarchy?
extend Referenced if source? and role and target.actor?
end
|
Instance Attribute Details
#direction ⇒ Object
Returns the value of attribute direction
8
9
10
|
# File 'lib/adjustable_schema/active_record/association.rb', line 8
def direction
@direction
end
|
#owner ⇒ Object
Returns the value of attribute owner
8
9
10
|
# File 'lib/adjustable_schema/active_record/association.rb', line 8
def owner
@owner
end
|
#role ⇒ Object
Returns the value of attribute role
8
9
10
|
# File 'lib/adjustable_schema/active_record/association.rb', line 8
def role
@role
end
|
#target ⇒ Object
Returns the value of attribute target
8
9
10
|
# File 'lib/adjustable_schema/active_record/association.rb', line 8
def target
@target
end
|
Instance Method Details
#child? ⇒ Boolean
52
|
# File 'lib/adjustable_schema/active_record/association.rb', line 52
def child? = (recursive? and source?)
|
#define ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/adjustable_schema/active_record/association.rb', line 36
def define
association = self
has_many name, **options do
include Scopes
include Scopes::Recursive if association.recursive?
end or return
define_scopes
define_methods
end
|
#hierarchy? ⇒ Boolean
54
|
# File 'lib/adjustable_schema/active_record/association.rb', line 54
def hierarchy? = (child? and roleless?)
|
#parent? ⇒ Boolean
53
|
# File 'lib/adjustable_schema/active_record/association.rb', line 53
def parent? = (recursive? and target?)
|
#recursive? ⇒ Boolean
48
|
# File 'lib/adjustable_schema/active_record/association.rb', line 48
def recursive? = target == owner
|
#roleless? ⇒ Boolean
49
|
# File 'lib/adjustable_schema/active_record/association.rb', line 49
def roleless? = !role
|
#source? ⇒ Boolean
50
|
# File 'lib/adjustable_schema/active_record/association.rb', line 50
def source? = direction == :source
|
#target? ⇒ Boolean
51
|
# File 'lib/adjustable_schema/active_record/association.rb', line 51
def target? = direction == :target
|