Module: CouchScheduler

Defined in:
lib/couch_scheduler/map.rb,
lib/couch_scheduler/couch_scheduler.rb,
lib/couch_scheduler/couch_publish_integration.rb,
lib/couch_scheduler/couch_visible_integration.rb

Defined Under Namespace

Modules: ClassMethods, CouchPublishIntegration, CouchVisibleIntegration Classes: Map

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/couch_scheduler/couch_scheduler.rb', line 2

def self.included(base)
  unless base.ancestors.include?(CouchView)
    base.send :include, CouchView
  end

  base.property :start, Date
  base.property :end, Date
  base.validate :validate_start_and_end
  base.extend ClassMethods

  base.couch_view :within_couch_schedule do
    map CouchScheduler::Map
  end

  if defined?(CouchPublish) && base.ancestors.include?(CouchPublish)
    base.send :include, CouchPublishIntegration
  end
  
  if defined?(CouchVisible) && base.ancestors.include?(CouchVisible)
    base.send :include, CouchVisibleIntegration
  end
end

Instance Method Details

#within_schedule?Boolean

Returns:

  • (Boolean)


43
44
45
46
47
48
49
50
51
# File 'lib/couch_scheduler/couch_scheduler.rb', line 43

def within_schedule?
  start_valid = true
  end_valid   = true

  start_valid = Time.now.to_date >= self.start  if self.start
  end_valid   = Time.now.to_date < self.end     if self.end

  start_valid && end_valid
end