Class: Rql::Dsl::Base
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(model, alias_derived_attr = false) ⇒ Base
constructor
A new instance of Base.
- #method_missing(method_name, *params) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(model, alias_derived_attr = false) ⇒ Base
Returns a new instance of Base.
4 5 6 7 |
# File 'lib/rql/dsl/base.rb', line 4 def initialize(model, alias_derived_attr = false) @model = model @alias_derived_attr = alias_derived_attr end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *params) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/rql/dsl/base.rb', line 13 def method_missing(method_name, *params) if respond_to_missing?(method_name) raise ArgumentError.new("wrong number of arguments for `#{method_name}' (given #{params.length}, expected 0)") if (params.length > 0) derive(method_name) || build_context(method_name) else super end end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
9 10 11 |
# File 'lib/rql/dsl/base.rb', line 9 def respond_to_missing?(method_name, include_private = false) derived?(method_name) || model?(method_name) || attribute?(method_name) || super end |