Class: Joiner::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/joiner/path.rb

Constant Summary collapse

AGGREGATE_MACROS =
[:has_many, :has_and_belongs_to_many]

Instance Method Summary collapse

Constructor Details

#initialize(base, path) ⇒ Path

Returns a new instance of Path.



4
5
6
# File 'lib/joiner/path.rb', line 4

def initialize(base, path)
  @base, @path = base, path
end

Instance Method Details

#aggregate?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/joiner/path.rb', line 8

def aggregate?
  macros.any? { |macro| AGGREGATE_MACROS.include? macro }
end

#macrosObject



12
13
14
# File 'lib/joiner/path.rb', line 12

def macros
  reflections.collect(&:macro)
end

#modelObject



16
17
18
# File 'lib/joiner/path.rb', line 16

def model
  path.empty? ? base : reflections.last.try(:klass)
end