Class: ShopifyAPI::ApiVersion

Inherits:
Object
  • Object
show all
Extended by:
DefinedVersions
Includes:
Comparable
Defined in:
lib/shopify_api/api_version.rb

Direct Known Subclasses

Release, Unstable

Defined Under Namespace

Classes: InvalidVersion, Release, UnknownVersion, Unstable

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DefinedVersions

define_known_versions

Class Method Details

.clear_defined_versionsObject



26
27
28
# File 'lib/shopify_api/api_version.rb', line 26

def self.clear_defined_versions
  @versions = {}
end

.coerce_to_version(version_or_name) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/shopify_api/api_version.rb', line 11

def self.coerce_to_version(version_or_name)
  return version_or_name if version_or_name.is_a?(ApiVersion)

  @versions ||= {}
  @versions.fetch(version_or_name.to_s) do
    raise UnknownVersion, "#{version_or_name} is not in the defined version set: #{@versions.keys.join(', ')}"
  end
end

.define_version(version) ⇒ Object



20
21
22
23
24
# File 'lib/shopify_api/api_version.rb', line 20

def self.define_version(version)
  @versions ||= {}

  @versions[version.name] = version
end

.latest_stable_versionObject



30
31
32
# File 'lib/shopify_api/api_version.rb', line 30

def self.latest_stable_version
  @versions.values.select(&:stable?).sort.last
end

Instance Method Details

#<=>(other) ⇒ Object



51
52
53
# File 'lib/shopify_api/api_version.rb', line 51

def <=>(other)
  numeric_version <=> other.numeric_version
end

#==(other) ⇒ Object



43
44
45
# File 'lib/shopify_api/api_version.rb', line 43

def ==(other)
  other.class == self.class && to_s == other.to_s
end

#construct_api_path(_path) ⇒ Object

Raises:

  • (NotImplementedError)


59
60
61
# File 'lib/shopify_api/api_version.rb', line 59

def construct_api_path(_path)
  raise NotImplementedError
end

#construct_graphql_pathObject

Raises:

  • (NotImplementedError)


63
64
65
# File 'lib/shopify_api/api_version.rb', line 63

def construct_graphql_path
  raise NotImplementedError
end

#hashObject



47
48
49
# File 'lib/shopify_api/api_version.rb', line 47

def hash
  @version_name.hash
end

#inspectObject



39
40
41
# File 'lib/shopify_api/api_version.rb', line 39

def inspect
  @version_name
end

#stable?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/shopify_api/api_version.rb', line 55

def stable?
  false
end

#to_sObject Also known as: name



34
35
36
# File 'lib/shopify_api/api_version.rb', line 34

def to_s
  @version_name
end