Sha256: 790ebc221ac05b2e8c5530e9b7bedb25a0b394b790669cf64be4031191e61367

Contents?: true

Size: 391 Bytes

Versions: 5

Compression:

Stored size: 391 Bytes

Contents

module ActionPresenter
  module Defaults
    module Timestamps
      [:created_at, :updated_at].each do |timestamp|
        define_method timestamp do |format = :default|
          localize_time timestamp, format
        end
      end

    private

      def localize_time(time, format)
        I18n.l(object.try(time), format: format) if object.respond_to?(time)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
action_presenter-1.1.6 lib/action_presenter/defaults/timestamps.rb
action_presenter-1.1.5 lib/action_presenter/defaults/timestamps.rb
action_presenter-1.1.4 lib/action_presenter/defaults/timestamps.rb
action_presenter-1.1.3 lib/action_presenter/defaults/timestamps.rb
action_presenter-1.1.2 lib/action_presenter/defaults/timestamps.rb