Class: ShopifyAPI::ApiAccess

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_api/api_access.rb

Constant Summary collapse

SCOPE_DELIMITER =
','

Instance Method Summary collapse

Constructor Details

#initialize(scope_names) ⇒ ApiAccess

Returns a new instance of ApiAccess.



7
8
9
10
11
12
13
# File 'lib/shopify_api/api_access.rb', line 7

def initialize(scope_names)
  if scope_names.is_a?(String)
    scope_names = scope_names.to_s.split(SCOPE_DELIMITER)
  end

  store_scopes(scope_names)
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



27
28
29
30
# File 'lib/shopify_api/api_access.rb', line 27

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

#covers?(scopes) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/shopify_api/api_access.rb', line 15

def covers?(scopes)
  scopes.compressed_scopes <= expanded_scopes
end

#hashObject



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

def hash
  compressed_scopes.hash
end

#to_aObject



23
24
25
# File 'lib/shopify_api/api_access.rb', line 23

def to_a
  compressed_scopes.to_a
end

#to_sObject



19
20
21
# File 'lib/shopify_api/api_access.rb', line 19

def to_s
  to_a.join(SCOPE_DELIMITER)
end