Class: Joiner::Path
- Inherits:
-
Object
- Object
- Joiner::Path
- Defined in:
- lib/joiner/path.rb
Constant Summary collapse
- AGGREGATE_MACROS =
[:has_many, :has_and_belongs_to_many]
Instance Method Summary collapse
- #aggregate? ⇒ Boolean
-
#initialize(base, path) ⇒ Path
constructor
A new instance of Path.
- #macros ⇒ Object
- #model ⇒ Object
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
8 9 10 |
# File 'lib/joiner/path.rb', line 8 def aggregate? macros.any? { |macro| AGGREGATE_MACROS.include? macro } end |
#macros ⇒ Object
12 13 14 |
# File 'lib/joiner/path.rb', line 12 def macros reflections.collect(&:macro) end |
#model ⇒ Object
16 17 18 |
# File 'lib/joiner/path.rb', line 16 def model path.empty? ? base : reflections.last.try(:klass) end |