Class: FilepickerRails::Configuration
- Inherits:
-
Object
- Object
- FilepickerRails::Configuration
- Defined in:
- lib/filepicker_rails/configuration.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #expiry ⇒ Object
-
#expiry=(expiry) ⇒ Object
Define the expire time when using Policy.
Instance Attribute Details
#api_key ⇒ Object
45 46 47 |
# File 'lib/filepicker_rails/configuration.rb', line 45 def api_key @api_key or raise "Set config.filepicker_rails.api_key" end |
#cdn_host ⇒ Object
42 43 44 |
# File 'lib/filepicker_rails/configuration.rb', line 42 def cdn_host @cdn_host end |
#secret_key ⇒ Object
27 28 29 |
# File 'lib/filepicker_rails/configuration.rb', line 27 def secret_key @secret_key end |
Instance Method Details
#expiry ⇒ Object
73 74 75 |
# File 'lib/filepicker_rails/configuration.rb', line 73 def expiry @expiry ||= -> { Time.zone.now.to_i + 600 } end |
#expiry=(expiry) ⇒ Object
Define the expire time when using Policy.
By default the expiry time is 10 minutes. If you need to change the expiry time this should be an integer and it is expressed in seconds since the [Epoch](en.wikipedia.org/wiki/Unix_time).
#### Examples
This is to be used on the ‘config/application.rb`:
config.filepicker_rails.expiry = -> { (Time.zone.now + 5.minutes).to_i }
# Define the expiry time to 5 minutes
If you need always the same url, a static expiry time, to do some cache. You can set a date starting of the Epoch.
config.filepicker_rails.expiry = -> { 100.years.since(Time.at(0)).to_i }
67 68 69 70 |
# File 'lib/filepicker_rails/configuration.rb', line 67 def expiry=(expiry) raise ArgumentError, 'Must be a callable' unless expiry.respond_to?(:call) @expiry = expiry end |