Sha256: 898118deda473a0fe817e4bcf0200706e262de0ded04ca007c8c63f4b0e9fd8b

Contents?: true

Size: 740 Bytes

Versions: 2

Compression:

Stored size: 740 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|
      if controller.ancestors.include?(ActionController::Base)
        unless controller.middleware_stack.include?(RawReferenceTime)
          controller.use RawReferenceTime
        end

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

        helper_method :requested_at
      end
    end

    private

    def requested_at
      Trice.reference_time
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trice-0.3.1 lib/trice/controller_methods.rb
trice-0.3.0 lib/trice/controller_methods.rb