Module: Paraphrase::Syntax::Base
- Defined in:
- lib/paraphrase/syntax.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#paraphrase(params) ⇒ Object
Instantiate the Query class that is mapped to
self. -
#paraphraser ⇒ Object
Attempts to find paraphrase class based on class name.
-
#register_mapping(&block) ⇒ Object
Create a Query subclass from a block using the
QueryDSL to map scopes to param keys.
Class Method Details
.extended(klass) ⇒ Object
4 5 6 7 8 |
# File 'lib/paraphrase/syntax.rb', line 4 def self.extended(klass) klass.instance_eval do class_attribute :_paraphraser, :instance_writer => false, :instance_reader => false end end |
Instance Method Details
#paraphrase(params) ⇒ Object
Instantiate the Query class that is mapped to self.
29 30 31 |
# File 'lib/paraphrase/syntax.rb', line 29 def paraphrase(params) self.paraphraser.new(params, self) end |
#paraphraser ⇒ Object
Attempts to find paraphrase class based on class name. Override if using a different naming convention.
20 21 22 23 24 |
# File 'lib/paraphrase/syntax.rb', line 20 def paraphraser self._paraphraser || "#{self.name}Query".constantize rescue nil end |
#register_mapping(&block) ⇒ Object
Create a Query subclass from a block using the Query DSL to map
scopes to param keys
14 15 16 |
# File 'lib/paraphrase/syntax.rb', line 14 def register_mapping(&block) self._paraphraser = Class.new(Query, &block) end |