module MetalArchives
Metal Archives Ruby API
Constants
- CACHE_STRATEGIES
- VERSION
Attributes
loader[R]
Code loader instance
Public Class Methods
cache()
click to toggle source
Cache
instance
# File lib/metal_archives.rb, line 41 def cache raise MetalArchives::Errors::InvalidConfigurationError, "cache has not been configured" unless config.cache_strategy @cache ||= Cache .const_get(loader.inflector.camelize(config.cache_strategy, root)) .new(config.cache_options) end
config()
click to toggle source
API configuration
Instance of MetalArchives::Configuration
# File lib/metal_archives.rb, line 34 def config @config ||= Configuration.new end
configure() { |config| ... }
click to toggle source
Configure API options.
A block must be specified, to which a MetalArchives::Configuration
parameter will be passed.
- Raises
-
InvalidConfigurationException
# File lib/metal_archives.rb, line 58 def configure raise Errors::InvalidConfigurationError, "no configuration block given" unless block_given? yield config config.validate! end
http()
click to toggle source
HTTP client
# File lib/metal_archives.rb, line 25 def http @http ||= HTTPClient.new end
root()
click to toggle source
Root path
# File lib/metal_archives.rb, line 18 def root @root ||= Pathname.new(File.expand_path(File.join("..", ".."), __FILE__)) end
setup()
click to toggle source
Set up application framework
# File lib/metal_archives.rb, line 69 def setup @loader = Zeitwerk::Loader.for_gem # Register inflections require root.join("config/inflections.rb") # Set up code loader loader.enable_reloading if ENV["METAL_ARCHIVES_ENV"] == "development" loader.collapse(root.join("lib/metal_archives/models")) loader.do_not_eager_load(root.join("lib/metal_archives/cache")) loader.setup loader.eager_load # Load initializers Dir[root.join("config/initializers/*.rb")].sort.each { |f| require f } end