Class: Babik::Selection::Path::Factory

Inherits:
Object
  • Object
show all
Defined in:
lib/babik/queryset/lib/selection/path/path.rb

Overview

Represents a factory class for ForeignPath & LocalPath

Class Method Summary collapse

Class Method Details

.build(model, selection_path) ⇒ Object

Factory Method used to create local and foreign selections



14
15
16
17
18
# File 'lib/babik/queryset/lib/selection/path/path.rb', line 14

def self.build(model, selection_path)
  is_foreign = selection_path.match?(Babik::Selection::Config::RELATIONSHIP_SEPARATOR)
  return Babik::Selection::Path::ForeignPath.new(model, selection_path) if is_foreign
  Babik::Selection::Path::LocalPath.new(model, selection_path)
end