class Versionist::VersioningStrategy::Parameter

Implements the parameter versioning strategy.

Public Class Methods

new(config) click to toggle source

Creates a new Parameter VersioningStrategy object. config must contain the following keys:

  • :parameter the parameter hash to inspect

# File lib/versionist/versioning_strategy/parameter.rb, line 8
def initialize(config)
  super
  raise ArgumentError, "you must specify :name in the :parameter configuration Hash" if !config[:parameter].has_key?(:name)
  raise ArgumentError, "you must specify :value in the :parameter configuration Hash" if !config[:parameter].has_key?(:value)
  Versionist.configuration.parameter_versions << self if !Versionist.configuration.parameter_versions.include?(self)
end

Public Instance Methods

==(other) click to toggle source
Calls superclass method Versionist::VersioningStrategy::Base#==
# File lib/versionist/versioning_strategy/parameter.rb, line 20
def ==(other)
  super
  return false if !other.is_a?(Versionist::VersioningStrategy::Parameter)
  return self.config[:parameter][:name] == other.config[:parameter][:name] && self.config[:parameter][:value] == other.config[:parameter][:value]
end
matches?(request) click to toggle source
# File lib/versionist/versioning_strategy/parameter.rb, line 15
def matches?(request)
  parameter_string = request.params[config[:parameter][:name]].to_s
  return !parameter_string.blank? && parameter_string == config[:parameter][:value]
end