Sha256: a4e66ba694d3a88967af67b1f231c74022ac3efdd3d3023b2598bb8d2e77c392

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 Bytes

Contents

module Mongoid
  module Timespanned
    extend ActiveSupport::Concern

    module ClassMethods
      def timespan_setters name = :period  
        define_method :"#{name}_start=" do |date|
          self.send "#{name}=", ::Timespan.new(start_date: date, end_date: self.send(name).end_date)
        end

        define_method :"#{name}_end=" do |date|
          self.send "#{name}=", ::Timespan.new(start_date: self.send(name).start_date, end_date: date)
        end

        define_method :"#{name}duration=" do |duration|
          self.send "#{name}=", ::Timespan.new(start_date: self.send(name).start_date, duration: duration)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timespan-0.4.2 lib/timespan/mongoid/timespanned.rb