Class: Clowne::Declarations::IncludeAssociation

Inherits:
Base
  • Object
show all
Defined in:
lib/clowne/declarations/include_association.rb

Overview

:nodoc: all

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, scope = nil, **options) ⇒ IncludeAssociation

Returns a new instance of IncludeAssociation.



12
13
14
15
16
# File 'lib/clowne/declarations/include_association.rb', line 12

def initialize(name, scope = nil, **options)
  @name = name.to_sym
  @scope = scope
  @options = options
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



10
11
12
# File 'lib/clowne/declarations/include_association.rb', line 10

def name
  @name
end

#optionsObject

Returns the value of attribute options.



10
11
12
# File 'lib/clowne/declarations/include_association.rb', line 10

def options
  @options
end

#scopeObject

Returns the value of attribute scope.



10
11
12
# File 'lib/clowne/declarations/include_association.rb', line 10

def scope
  @scope
end

Instance Method Details

#clone_withObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/clowne/declarations/include_association.rb', line 35

def clone_with
  return @clone_with if instance_variable_defined?(:@clone_with)

  @clone_with =
    case options[:clone_with]
    when String, Symbol
      options[:clone_with].to_s.constantize
    else
      options[:clone_with]
    end
end

#compile(plan) ⇒ Object



18
19
20
# File 'lib/clowne/declarations/include_association.rb', line 18

def compile(plan)
  plan.add_to(:association, name, self)
end

#matches?(names) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/clowne/declarations/include_association.rb', line 22

def matches?(names)
  names = Array(names)
  names.include?(name)
end

#paramsObject



31
32
33
# File 'lib/clowne/declarations/include_association.rb', line 31

def params
  options[:params]
end

#params_proxyObject



27
28
29
# File 'lib/clowne/declarations/include_association.rb', line 27

def params_proxy
  @_params_proxy ||= Clowne::Utils::Params.proxy(options[:params])
end

#traitsObject



47
48
49
# File 'lib/clowne/declarations/include_association.rb', line 47

def traits
  options[:traits]
end