Module: LocalResource
- Extended by:
- LocalResource
- Included in:
- LocalResource
- Defined in:
- lib/local_resource.rb,
lib/local_resource/engine.rb,
lib/local_resource/version.rb,
lib/local_resource/instance.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
'0.1.0'
Instance Method Summary collapse
- #as_local_resource(url, tmp_filename, &block) ⇒ Object
-
#setup {|_self| ... } ⇒ Object
You can add, in this module, your own configuration options as in the example below…
Instance Method Details
#as_local_resource(url, tmp_filename, &block) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/local_resource.rb', line 26 def as_local_resource(url, tmp_filename, &block) instance = LocalResource::Instance.new(url, tmp_filename) block.call(instance.file_path) ensure instance&.destroy end |
#setup {|_self| ... } ⇒ Object
You can add, in this module, your own configuration options as in the example below…
attr_writer :my_option
def my_option
return "Default Value" unless @my_option
@my_option
end
Then, you can customize the default behaviour (typically in a Rails initializer) like this:
LocalResource.setup do |config|
config.root_url = "Another value"
end
21 22 23 24 |
# File 'lib/local_resource.rb', line 21 def setup yield self require "local_resource" end |