Module: Showroom
- Extended by:
- Core::Configurable
- Defined in:
- lib/showroom.rb,
lib/showroom/client.rb,
lib/showroom/core/error.rb,
lib/showroom/core/default.rb,
lib/showroom/core/version.rb,
lib/showroom/models/search.rb,
lib/showroom/core/countable.rb,
lib/showroom/core/store_url.rb,
lib/showroom/models/product.rb,
lib/showroom/core/connection.rb,
lib/showroom/models/resource.rb,
lib/showroom/core/configurable.rb,
lib/showroom/models/collection.rb,
lib/showroom/models/product_image.rb,
lib/showroom/models/search/result.rb,
lib/showroom/models/product_option.rb,
lib/showroom/models/product_variant.rb,
lib/showroom/models/search/suggestion.rb,
lib/showroom/http/middleware/raise_error.rb,
lib/showroom/models/search/page_suggestion.rb,
lib/showroom/models/search/query_suggestion.rb,
lib/showroom/models/search/article_suggestion.rb,
lib/showroom/models/search/product_suggestion.rb,
lib/showroom/models/search/collection_suggestion.rb
Overview
Top-level namespace for the Showroom gem.
Acts as a module-level client with Core::Configurable mixed in, so you can configure and use Showroom directly without instantiating a Client.
Defined Under Namespace
Modules: Core, Http, Search Classes: BadRequest, Client, ClientError, Collection, ConfigurationError, ConnectionError, Error, InvalidResponse, NotFound, Product, ProductImage, ProductOption, ProductVariant, Resource, ResponseError, ServerError, TooManyRequests, UnprocessableEntity
Constant Summary
Constants included from Core::Configurable
Class Method Summary collapse
-
.client ⇒ Client
Returns the memoized module-level Client.
-
.collection(handle) ⇒ Collection
Fetches a single collection by handle from the configured store.
-
.collections(**params) ⇒ Array<Collection>
Fetches collections from the configured store.
-
.configure {|self| ... } ⇒ self
Configures the module and resets the memoized client so the next call to Showroom.client picks up the new settings.
-
.product(handle) ⇒ Product
Fetches a single product by handle from the configured store.
-
.products(**params) ⇒ Array<Product>
Fetches products from the configured store.
-
.reset! ⇒ void
Resets all configuration to defaults and clears the memoized client.
-
.search(query_str) ⇒ Search::Result
Calls the Shopify search suggest endpoint and returns a Search::Result.
-
.setup {|self| ... } ⇒ self
Alias for Showroom.configure — yields self for block-style setup.
Methods included from Core::Configurable
configure, options, per_page=, reset!, same_options?, store, store=
Class Method Details
.client ⇒ Client
Returns the memoized module-level Client.
33 34 35 |
# File 'lib/showroom.rb', line 33 def self.client @client ||= Client.new(**) end |
.collection(handle) ⇒ Collection
Fetches a single collection by handle from the configured store.
92 93 94 |
# File 'lib/showroom.rb', line 92 def self.collection(handle) Collection.find(handle) end |
.collections(**params) ⇒ Array<Collection>
Fetches collections from the configured store.
83 84 85 |
# File 'lib/showroom.rb', line 83 def self.collections(**params) Collection.where(**params) end |
.configure {|self| ... } ⇒ self
Configures the module and resets the memoized client so the next call to client picks up the new settings.
42 43 44 |
# File 'lib/showroom.rb', line 42 def self.configure super.tap { @client = nil } end |
.product(handle) ⇒ Product
Fetches a single product by handle from the configured store.
75 76 77 |
# File 'lib/showroom.rb', line 75 def self.product(handle) Product.find(handle) end |
.products(**params) ⇒ Array<Product>
Fetches products from the configured store.
66 67 68 |
# File 'lib/showroom.rb', line 66 def self.products(**params) Product.where(**params) end |
.reset! ⇒ void
This method returns an undefined value.
Resets all configuration to defaults and clears the memoized client.
49 50 51 52 |
# File 'lib/showroom.rb', line 49 def self.reset! super @client = nil end |
.search(query_str) ⇒ Search::Result
Calls the Shopify search suggest endpoint and returns a Showroom::Search::Result.
All keyword arguments are forwarded verbatim to Showroom::Search.suggest (accepted keys: types:, limit:; see Showroom::Search.suggest for details).
103 104 105 |
# File 'lib/showroom.rb', line 103 def self.search(query_str, **) Search.suggest(query_str, **) end |
.setup {|self| ... } ⇒ self
Alias for configure — yields self for block-style setup.
58 59 60 |
# File 'lib/showroom.rb', line 58 def self.setup(&) configure(&) end |