Class: Picker
- Inherits:
-
Object
- Object
- Picker
- Defined in:
- lib/filestack_rails/filestack_js.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #domain ⇒ Object
- #filestack_js_url ⇒ Object
-
#initialize ⇒ Picker
constructor
A new instance of Picker.
- #picker(client_name, api_key, options, callback, other_callbacks = nil) ⇒ Object
- #security(signature, policy) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize ⇒ Picker
Returns a new instance of Picker.
4 5 6 |
# File 'lib/filestack_rails/filestack_js.rb', line 4 def initialize @url = filestack_js_url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
2 3 4 |
# File 'lib/filestack_rails/filestack_js.rb', line 2 def url @url end |
Instance Method Details
#domain ⇒ Object
16 17 18 |
# File 'lib/filestack_rails/filestack_js.rb', line 16 def domain ::Rails.application.config.filestack_rails.cname || 'filestackapi.com' end |
#filestack_js_url ⇒ Object
8 9 10 |
# File 'lib/filestack_rails/filestack_js.rb', line 8 def filestack_js_url "https://static.#{domain}/filestack-js/#{version}/filestack.min.js" end |
#picker(client_name, api_key, options, callback, other_callbacks = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/filestack_rails/filestack_js.rb', line 20 def picker(client_name, api_key, , callback, other_callbacks = nil) = [1..-2] # removed curly brackets help to generate pickerOptions in js <<~HTML (function(){ #{client_name}.picker({ onUploadDone: data => #{callback}(data)#{other_callbacks}, #{} }).open() })() HTML end |
#security(signature, policy) ⇒ Object
30 31 32 |
# File 'lib/filestack_rails/filestack_js.rb', line 30 def security(signature, policy) { security: { signature: signature, policy: policy } }.to_json end |
#version ⇒ Object
12 13 14 |
# File 'lib/filestack_rails/filestack_js.rb', line 12 def version ::Rails.application.config.filestack_rails.version end |