Class: Microscope::Scope::DatetimeScope

Inherits:
Microscope::Scope show all
Defined in:
lib/microscope/scope/datetime_scope.rb

Direct Known Subclasses

DateScope

Instance Attribute Summary

Attributes inherited from Microscope::Scope

#field, #model

Instance Method Summary collapse

Methods inherited from Microscope::Scope

#cropped_field, inject_scopes, #quoted_field

Constructor Details

#initialize(*args) ⇒ DatetimeScope

Returns a new instance of DatetimeScope.



4
5
6
7
8
9
10
11
12
# File 'lib/microscope/scope/datetime_scope.rb', line 4

def initialize(*args)
  super

  @now = 'Time.now'
  @now_suffix = '_now'
  @specific_suffix = '_at'
  @cropped_field_regex = /_at$/
  @formatted_time = 'time'
end

Instance Method Details

#applyObject



14
15
16
# File 'lib/microscope/scope/datetime_scope.rb', line 14

def apply
  model.class_eval(apply_scopes) if @field_name =~ @cropped_field_regex
end