class ShopifyAPI::ApiAccess
Constants
- SCOPE_DELIMITER
Attributes
compressed_scopes[R]
expanded_scopes[R]
Public Class Methods
new(scope_names)
click to toggle source
# 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
Public Instance Methods
==(other)
click to toggle source
# File lib/shopify_api/api_access.rb, line 27 def ==(other) other.class == self.class && compressed_scopes == other.compressed_scopes end
Also aliased as: eql?
covers?(scopes)
click to toggle source
# File lib/shopify_api/api_access.rb, line 15 def covers?(scopes) scopes.compressed_scopes <= expanded_scopes end
hash()
click to toggle source
# File lib/shopify_api/api_access.rb, line 34 def hash compressed_scopes.hash end
to_a()
click to toggle source
# File lib/shopify_api/api_access.rb, line 23 def to_a compressed_scopes.to_a end
to_s()
click to toggle source
# File lib/shopify_api/api_access.rb, line 19 def to_s to_a.join(SCOPE_DELIMITER) end
Private Instance Methods
implied_scope(scope)
click to toggle source
# File lib/shopify_api/api_access.rb, line 52 def implied_scope(scope) is_write_scope = scope =~ /\A(unauthenticated_)?write_(.*)\z/ "#{$1}read_#{$2}" if is_write_scope end
store_scopes(scope_names)
click to toggle source
# File lib/shopify_api/api_access.rb, line 44 def store_scopes(scope_names) scopes = scope_names.map(&:strip).reject(&:empty?).to_set implied_scopes = scopes.map { |scope| implied_scope(scope) }.compact @compressed_scopes = scopes - implied_scopes @expanded_scopes = scopes + implied_scopes end