Class: WhereLower::ScopeSpawner
- Inherits:
-
Object
- Object
- WhereLower::ScopeSpawner
- Defined in:
- lib/where_lower/scope_spawner.rb
Overview
:nodoc:
Direct Known Subclasses
Defined Under Namespace
Classes: ArrayScopeSpawner, BasicScopeSpawner, EqualScopeSpawner, HashScopeSpawner, RangeScopeSpawner, StringScopeSpawner
Instance Attribute Summary collapse
-
#column_or_table_name ⇒ Object
readonly
:nodoc:.
-
#prefix ⇒ Object
readonly
:nodoc:.
-
#scope ⇒ Object
readonly
:nodoc:.
-
#value ⇒ Object
readonly
:nodoc:.
Class Method Summary collapse
-
.spawn(*args) ⇒ Object
Spawn different scopes based on value Just delegates to new though.
Instance Method Summary collapse
-
#initialize(scope, column_or_table_name, value, prefix = nil) ⇒ ScopeSpawner
constructor
Assign ivar only Actual operation is in #spawn.
-
#spawn ⇒ ActiveRecord::Relation
Spawn different scopes based on value Data conversion and query string generation are handled by different spanwer classes.
Constructor Details
#initialize(scope, column_or_table_name, value, prefix = nil) ⇒ ScopeSpawner
Assign ivar only Actual operation is in #spawn
31 32 33 34 35 36 |
# File 'lib/where_lower/scope_spawner.rb', line 31 def initialize(scope, column_or_table_name, value, prefix = nil) @scope = scope @column_or_table_name = column_or_table_name @value = value @prefix = prefix end |
Instance Attribute Details
#column_or_table_name ⇒ Object (readonly)
:nodoc:
5 6 7 |
# File 'lib/where_lower/scope_spawner.rb', line 5 def column_or_table_name @column_or_table_name end |
#prefix ⇒ Object (readonly)
:nodoc:
5 6 7 |
# File 'lib/where_lower/scope_spawner.rb', line 5 def prefix @prefix end |
#scope ⇒ Object (readonly)
:nodoc:
5 6 7 |
# File 'lib/where_lower/scope_spawner.rb', line 5 def scope @scope end |
#value ⇒ Object (readonly)
:nodoc:
5 6 7 |
# File 'lib/where_lower/scope_spawner.rb', line 5 def value @value end |
Class Method Details
.spawn(*args) ⇒ Object
Spawn different scopes based on value Just delegates to new though
13 14 15 |
# File 'lib/where_lower/scope_spawner.rb', line 13 def self.spawn(*args) new(*args).spawn end |
Instance Method Details
#spawn ⇒ ActiveRecord::Relation
Spawn different scopes based on value Data conversion and query string generation are handled by different spanwer classes
42 43 44 45 |
# File 'lib/where_lower/scope_spawner.rb', line 42 def spawn CLASS_TO_SPAWNER_CLASS_MAPPINGS[value.class]. spawn(*scope_arguments) end |