Class: ShopifyURL::Store

Inherits:
Linker
  • Object
show all
Defined in:
lib/shopify_url.rb

Defined Under Namespace

Classes: Blogs, Collections, Product, Products

Instance Method Summary collapse

Methods inherited from Linker

#to_s

Constructor Details

#initialize(shop) ⇒ Store

Returns a new instance of Store.



79
80
81
82
83
84
# File 'lib/shopify_url.rb', line 79

def initialize(shop)
  super

  host << TOP_LEVEL_DOMAIN unless @host =~ %r{\.[-0-9a-z]+\z} # non-ASCII domains!
  host.freeze
end

Instance Method Details

#blogs(category, query = nil) ⇒ Object



110
111
112
113
# File 'lib/shopify_url.rb', line 110

def blogs(category, query = nil)
  raise "category required" if empty?(category)
  Blogs.new(host, category, q(query))
end

#collection(id, query = nil) ⇒ Object



86
87
88
89
# File 'lib/shopify_url.rb', line 86

def collection(id, query = nil)
  id_required!(id)
  Collections.new(host, id, q(query))
end

#collections(query = nil) ⇒ Object



91
92
93
# File 'lib/shopify_url.rb', line 91

def collections(query = nil)
  Collections.new(host, nil, q(query))
end

#page(id, query = nil) ⇒ Object



104
105
106
107
108
# File 'lib/shopify_url.rb', line 104

def page(id, query = nil)
  url = host + "/pages/" << id.to_s
  url << "?" << q(query) if query
  url
end

#product(id, query = nil) ⇒ Object



95
96
97
98
# File 'lib/shopify_url.rb', line 95

def product(id, query = nil)
  id_required!(id)
  Product.new(host, id, q(query))
end

#products(query = nil) ⇒ Object



100
101
102
# File 'lib/shopify_url.rb', line 100

def products(query = nil)
   Products.new(host, q(query))
end