Class: Rql::Dsl::Base

Inherits:
Object show all
Defined in:
lib/rql/dsl/base.rb

Direct Known Subclasses

Context

Instance Method Summary collapse

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

Returns:

  • (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