Module: Rql::Queryable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/rql/queryable.rb
Class Method Summary collapse
-
.derive(*attributes) ⇒ Object
Preloads the specified derived attributes from the database.
-
.derive_attr(name) { ... } ⇒ Object
Defines a derived attribute on a model.
-
.derived_attributes ⇒ Hash<Symbol, Proc>
Gets the derived attributes defined on the model.
-
.eval_rql(alias_derived_attr = false) { ... } ⇒ Rql::Dsl::Context
Evaluates a block of code against the RQL DSL.
-
.rql ⇒ Rql::Scope::RqlScope
Gets an RQL scope object for access to rql query methods.
Class Method Details
.derive(*attributes) ⇒ Object
Preloads the specified derived attributes from the database
42 43 44 |
# File 'lib/rql/queryable.rb', line 42 def derive(*attributes) rql.select(self.arel_table[Arel.star], *attributes).all end |
.derive_attr(name) { ... } ⇒ Object
Defines a derived attribute on a model
30 31 32 33 34 35 36 |
# File 'lib/rql/queryable.rb', line 30 def derive_attr(name, &block) define_method(name) do attributes.has_key?(name.to_s) ? attributes[name.to_s] : instance_eval(&block) end derived_attributes[name] = block end |
.derived_attributes ⇒ Hash<Symbol, Proc>
Gets the derived attributes defined on the model
49 50 51 |
# File 'lib/rql/queryable.rb', line 49 def derived_attributes @derive_attribute ||= {} end |
.eval_rql(alias_derived_attr = false) { ... } ⇒ Rql::Dsl::Context
Evaluates a block of code against the RQL DSL
20 21 22 |
# File 'lib/rql/queryable.rb', line 20 def eval_rql(alias_derived_attr = false, &block) Dsl::Base.new(self, alias_derived_attr).instance_eval(&block) end |
.rql ⇒ Rql::Scope::RqlScope
Gets an RQL scope object for access to rql query methods
11 12 13 |
# File 'lib/rql/queryable.rb', line 11 def rql return Scope::RqlScope.new(all) end |