Module: Eel::CoreExt::SymbolExtensions
- Defined in:
- lib/eel/core_ext/symbol_extensions.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/eel/core_ext/symbol_extensions.rb', line 28
def method_missing method_name, *args, &block
if method_name.in? predicates
if args.present?
attr.send(method_name, *args) else
attr.send(method_name) end
else
super
end
end
|
Instance Method Details
#attr ⇒ Object
5
6
7
|
# File 'lib/eel/core_ext/symbol_extensions.rb', line 5
def attr
Arel::Attributes::Attribute.new(nil, self)
end
|
#of(val) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/eel/core_ext/symbol_extensions.rb', line 9
def of val
relation = case val
when Class
val.arel_table
when Symbol
val
when String
Arel::Table.new(val)
else
raise "Can't use #{val.class} as a relation"
end
Arel::Attributes::Attribute.new(relation, self)
end
|
#respond_to_missing?(method_name, private = false) ⇒ Boolean
24
25
26
|
# File 'lib/eel/core_ext/symbol_extensions.rb', line 24
def respond_to_missing? method_name, private = false
method_name.in? predicates
end
|