Sha256: 65c0a32ffa53ca2dda126e7e74859c6437cf260f926cbd45edc07c586495d88b

Contents?: true

Size: 761 Bytes

Versions: 1

Compression:

Stored size: 761 Bytes

Contents

require 'trice/controller_methods/raw_reference_time'
require 'trice/controller_methods/reference_time_assignment'
require 'trice/controller_methods/stub_configuration'

module Trice
  module ControllerMethods

    extend ActiveSupport::Concern

    included do |controller|
      unless controller.middleware_stack.include?(RawReferenceTime)
        controller.use RawReferenceTime
      end

      config = StubConfiguration.new(Trice.support_requested_at_stubbing)
      prepend_around_action ReferenceTimeAssignment.new(config)

      # ActionController::API doesn't have helper_method
      if respond_to?(:helper_method)
        helper_method :requested_at
      end
    end

    private

    def requested_at
      Trice.reference_time
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trice-0.3.2 lib/trice/controller_methods.rb