Class: Shopifydev::Shop

Inherits:
Object
  • Object
show all
Defined in:
lib/shopifydev/shop.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials) ⇒ Shop

Returns a new instance of Shop.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/shopifydev/shop.rb', line 8

def initialize(credentials)
  @credentials = credentials
  @logger = Logger.new(STDOUT)

  ShopifyAPI::Base.clear_session
  if credentials['token']
    session = ShopifyAPI::Session.new(credentials['url'], credentials['token'])
    session.valid?  # returns true
    ShopifyAPI::Base.activate_session(session)
  else
    ShopifyAPI::Base.site = "https://" + 
      credentials['api_key'] + ':' + 
      credentials['password'] + '@' + 
      credentials['url'] + '/admin' 
    logger.debug("set shopify site to #{ShopifyAPI::Base.site}")
  end
end

Instance Attribute Details

#credentialsObject

Returns the value of attribute credentials.



6
7
8
# File 'lib/shopifydev/shop.rb', line 6

def credentials
  @credentials
end

#loggerObject

Returns the value of attribute logger.



6
7
8
# File 'lib/shopifydev/shop.rb', line 6

def logger
  @logger
end

#project_rootObject

Returns the value of attribute project_root.



6
7
8
# File 'lib/shopifydev/shop.rb', line 6

def project_root
  @project_root
end

Instance Method Details

#asset(path) ⇒ Object



40
41
42
# File 'lib/shopifydev/shop.rb', line 40

def asset(path)
  Asset.new(self, path, project_root)
end

#templateObject



36
37
38
# File 'lib/shopifydev/shop.rb', line 36

def template
  @template ||= Template.new(self, project_root)
end