Sha256: eb0bc5f742f7cfc882c0e9b69a32966de942c04bc66c5c9412cf5fa84db73fd7

Contents?: true

Size: 610 Bytes

Versions: 103

Compression:

Stored size: 610 Bytes

Contents

module CalculateStat

  def self.included(base)
    base.extend ClassMethods
    base.send :include, InstanceMethods
    base.class_eval do
      validates_presence_of :start_date, :end_date
      validate :check_date
    end
  end

  module ClassMethods
    def calculate_stat
      self.not_calculated.each do |stat|
        stat.aasm_calculate!
      end
    end
  end

  module InstanceMethods
    def check_date
      if self.start_date and self.end_date
        if self.start_date >= self.end_date
          errors.add(:start_date)
          errors.add(:end_date)
        end
      end
    end
  end
end

Version data entries

103 entries across 94 versions & 3 rubygems

Version Path
enju_circulation-0.0.21 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.20 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.19 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.18 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.17 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.16 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.15 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.0.7 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.14 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.0.6 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.0.5 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.13 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.12 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.11 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.10 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.9 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.8 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.7 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.0.4 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.6 spec/dummy/lib/enju_leaf/calculate_stat.rb