Sha256: 385bb14290fc3af272afad7278fd054de71b4b8665cec45d0da3af4a74fe954c

Contents?: true

Size: 534 Bytes

Versions: 2

Compression:

Stored size: 534 Bytes

Contents

module Contexts
  class Base
    def key
    end

    def required?
      true
    end

    def current
    end

    def default
    end

    def constraints
    end

    def url_option
      current
    end

    def apply(controller, value)
    end

    def matches_constraints?(request)
      if (con = constraints).nil?
        true
      elsif con.respond_to?(:matches?)
        con.matches?(request)
      elsif con.is_a?(Proc)
        con.call(request)
      else
        con === request.params[key]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
contexts-0.1.1 lib/contexts/base.rb
contexts-0.1.0 lib/contexts/base.rb