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.65 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.0.21 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.0.21 lib/enju_bookmark/calculate_stat.rb
enju_circulation-0.0.64 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.63 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.0.20 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.0.20 lib/enju_bookmark/calculate_stat.rb
enju_circulation-0.0.62 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.61 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.60 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.59 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.58 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.57 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.0.19 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.56 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.55 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.54 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.53 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.52 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.51 spec/dummy/lib/enju_leaf/calculate_stat.rb