Module: Showroom::Core::Default
- Defined in:
- lib/showroom/core/default.rb
Overview
Provides default configuration values for the gem, with optional overrides via environment variables.
Constant Summary collapse
- MAX_PER_PAGE =
Maximum allowed value for per_page.
250
Class Method Summary collapse
-
.connection_options ⇒ Hash
Extra options passed to Faraday connection.
-
.debug ⇒ Boolean
Whether to print debug output for each request.
-
.middleware ⇒ nil
No custom middleware by default.
-
.open_timeout ⇒ Integer
Open (connect) timeout in seconds.
-
.pagination_depth ⇒ Integer
Maximum number of pages to fetch during pagination.
-
.per_page ⇒ Integer
Number of results per page, clamped to MAX_PER_PAGE.
-
.store ⇒ nil
Store is required and has no default.
-
.timeout ⇒ Integer
Read timeout in seconds.
-
.user_agent ⇒ String
Default User-Agent header value.
Class Method Details
.connection_options ⇒ Hash
Returns extra options passed to Faraday connection.
51 52 53 |
# File 'lib/showroom/core/default.rb', line 51 def self. {} end |
.debug ⇒ Boolean
Returns whether to print debug output for each request.
56 57 58 |
# File 'lib/showroom/core/default.rb', line 56 def self.debug # rubocop:disable Naming/PredicateMethod ENV.fetch('SHOWROOM_DEBUG', nil) == '1' end |
.middleware ⇒ nil
Returns no custom middleware by default.
46 47 48 |
# File 'lib/showroom/core/default.rb', line 46 def self.middleware nil end |
.open_timeout ⇒ Integer
Returns open (connect) timeout in seconds.
36 37 38 |
# File 'lib/showroom/core/default.rb', line 36 def self.open_timeout ENV.fetch('SHOWROOM_OPEN_TIMEOUT', 10).to_i end |
.pagination_depth ⇒ Integer
Returns maximum number of pages to fetch during pagination.
31 32 33 |
# File 'lib/showroom/core/default.rb', line 31 def self.pagination_depth 50 end |
.per_page ⇒ Integer
Returns number of results per page, clamped to MAX_PER_PAGE.
25 26 27 28 |
# File 'lib/showroom/core/default.rb', line 25 def self.per_page raw = ENV.fetch('SHOWROOM_PER_PAGE', MAX_PER_PAGE).to_i [raw, MAX_PER_PAGE].min end |
.store ⇒ nil
Returns store is required and has no default.
12 13 14 |
# File 'lib/showroom/core/default.rb', line 12 def self.store ENV.fetch('SHOWROOM_STORE', nil) end |
.timeout ⇒ Integer
Returns read timeout in seconds.
41 42 43 |
# File 'lib/showroom/core/default.rb', line 41 def self.timeout ENV.fetch('SHOWROOM_TIMEOUT', 30).to_i end |
.user_agent ⇒ String
Returns default User-Agent header value.
17 18 19 20 21 22 |
# File 'lib/showroom/core/default.rb', line 17 def self.user_agent ENV.fetch( 'SHOWROOM_USER_AGENT', "Showroom/#{VERSION} (+https://github.com/01max/showroom; Ruby/#{RUBY_VERSION})" ) end |