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
# File 'lib/microscope/scope/datetime_scope.rb', line 4

def initialize(*args)
  super

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

Instance Method Details

#applyObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/microscope/scope/datetime_scope.rb', line 12

def apply
  return unless @field_name =~ @cropped_field_regex

  model.class_eval <<-RUBY, __FILE__, __LINE__ + 1
    #{before_scopes}
    #{after_scopes}
    #{between_scopes}
    #{boolean_scopes}
  RUBY
end