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_bookmark-0.1.2.pre3 lib/enju_bookmark/calculate_stat.rb
enju_bookmark-0.1.2.pre3 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.1.2.pre2 lib/enju_bookmark/calculate_stat.rb
enju_bookmark-0.1.2.pre2 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.1.2.pre lib/enju_bookmark/calculate_stat.rb
enju_bookmark-0.1.2.pre spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.1.1 lib/enju_bookmark/calculate_stat.rb
enju_bookmark-0.1.1 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.1.0.pre lib/enju_bookmark/calculate_stat.rb
enju_bookmark-0.1.0.pre spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.1.0 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_bookmark-0.1.0 lib/enju_bookmark/calculate_stat.rb
enju_bookmark-0.0.22 lib/enju_bookmark/calculate_stat.rb
enju_bookmark-0.0.22 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.71 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.70 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.69 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.68 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.67 spec/dummy/lib/enju_leaf/calculate_stat.rb
enju_circulation-0.0.66 spec/dummy/lib/enju_leaf/calculate_stat.rb