Sha256: 86c5aeaf1b0c4e2f23a9bcb729c740376bad8c983c40d8c4059151dd3aae3f79

Contents?: true

Size: 835 Bytes

Versions: 2

Compression:

Stored size: 835 Bytes

Contents

module MicroSessions
  module Controller
    extend ActiveSupport::Concern
  
    module ClassMethods
      def micro_sessions(options = {})
        options.stringify_keys!
        options.assert_valid_keys(:param, :param_type, :key, :length, :counter)
        
        options[:param] ||= "_msid"
        options[:key] ||= "_micro_sessions"
        options[:param_type] ||= :hash
        options[:length] ||= 10
        options[:counter] ||= 1
        
        class_inheritable_accessor :micro_session_options
        self.micro_session_options = options
        
        class_eval do
          def micro_session
            @micro_session ||= MicroSessions::MicroSession.new(self)
          end
          
          helper_method :micro_session
          helper_method :micro_session_options
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
micro_sessions-0.1.1 lib/micro_sessions/controller.rb
micro_sessions-0.1.0 lib/micro_sessions/controller.rb