Class: Versionist::VersioningStrategy::Path

Inherits:
Base
  • Object
show all
Defined in:
lib/versionist/versioning_strategy/path.rb

Overview

Implements the path versioning strategy. It expects the following path format: GET /<version>/…

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Path

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

  • :path the path prefix containing the version

Raises:

  • (ArgumentError)


9
10
11
12
13
# File 'lib/versionist/versioning_strategy/path.rb', line 9

def initialize(config)
  super
  raise ArgumentError, "you must specify :value in the :path configuration Hash" if !config[:path].has_key?(:value)
  Versionist.configuration.path_versions << self if !Versionist.configuration.path_versions.include?(self)
end

Instance Method Details

#==(other) ⇒ Object



15
16
17
18
19
# File 'lib/versionist/versioning_strategy/path.rb', line 15

def ==(other)
  super
  return false if !other.is_a?(Versionist::VersioningStrategy::Path)
  return config[:path][:value] == other.config[:path][:value]
end