Class: Groupdate::Series
- Inherits:
-
Object
- Object
- Groupdate::Series
- Defined in:
- lib/groupdate/series.rb
Instance Attribute Summary collapse
-
#magic ⇒ Object
Returns the value of attribute magic.
-
#relation ⇒ Object
Returns the value of attribute relation.
Instance Method Summary collapse
-
#initialize(magic, relation) ⇒ Series
constructor
A new instance of Series.
-
#method_missing(method, *args, &block) ⇒ Object
clone to prevent modifying original variables.
- #respond_to?(method, include_all = false) ⇒ Boolean
- #reverse_order_value ⇒ Object
Constructor Details
#initialize(magic, relation) ⇒ Series
Returns a new instance of Series.
5 6 7 8 |
# File 'lib/groupdate/series.rb', line 5 def initialize(magic, relation) @magic = magic @relation = relation end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
clone to prevent modifying original variables
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/groupdate/series.rb', line 11 def method_missing(method, *args, &block) # https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/calculations.rb if ActiveRecord::Calculations.method_defined?(method) magic.perform(relation, method, *args, &block) elsif @relation.respond_to?(method, true) Groupdate::Series.new(magic, relation.send(method, *args, &block)) else super end end |
Instance Attribute Details
#magic ⇒ Object
Returns the value of attribute magic.
3 4 5 |
# File 'lib/groupdate/series.rb', line 3 def magic @magic end |
#relation ⇒ Object
Returns the value of attribute relation.
3 4 5 |
# File 'lib/groupdate/series.rb', line 3 def relation @relation end |
Instance Method Details
#respond_to?(method, include_all = false) ⇒ Boolean
22 23 24 |
# File 'lib/groupdate/series.rb', line 22 def respond_to?(method, include_all = false) ActiveRecord::Calculations.method_defined?(method) || relation.respond_to?(method) || super end |
#reverse_order_value ⇒ Object
26 27 28 |
# File 'lib/groupdate/series.rb', line 26 def reverse_order_value nil end |