Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
1c88a725
Commit
1c88a725
authored
Jan 27, 2012
by
Benjamin Hüttinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed is_a?(Proc) to responds_to?(:call) for better flexibility
parent
87426153
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
lib/paperclip/storage/fog.rb
+5
-3
No files found.
lib/paperclip/storage/fog.rb
View file @
1c88a725
...
@@ -126,7 +126,7 @@ module Paperclip
...
@@ -126,7 +126,7 @@ module Paperclip
def
public_url
(
style
=
default_style
)
def
public_url
(
style
=
default_style
)
if
@options
[
:fog_host
]
if
@options
[
:fog_host
]
host
=
if
@options
[
:fog_host
].
is_a?
(
Proc
)
host
=
if
@options
[
:fog_host
].
respond_to?
(
:call
)
@options
[
:fog_host
].
call
(
self
)
@options
[
:fog_host
].
call
(
self
)
else
else
(
@options
[
:fog_host
]
=~
/%d/
)
?
@options
[:
fog_host
]
%
(
path
(
style
).
hash
%
4
)
:
@options
[
:fog_host
]
(
@options
[
:fog_host
]
=~
/%d/
)
?
@options
[:
fog_host
]
%
(
path
(
style
).
hash
%
4
)
:
@options
[
:fog_host
]
...
@@ -163,19 +163,21 @@ module Paperclip
...
@@ -163,19 +163,21 @@ module Paperclip
YAML
::
load
(
ERB
.
new
(
File
.
read
(
creds
)).
result
)
YAML
::
load
(
ERB
.
new
(
File
.
read
(
creds
)).
result
)
when
Hash
when
Hash
creds
creds
when
Proc
else
if
creds
.
respond_to?
(
:call
)
creds
.
call
(
self
)
creds
.
call
(
self
)
else
else
raise
ArgumentError
,
"Credentials are not a path, file, hash or proc."
raise
ArgumentError
,
"Credentials are not a path, file, hash or proc."
end
end
end
end
end
def
connection
def
connection
@connection
||=
::
Fog
::
Storage
.
new
(
fog_credentials
)
@connection
||=
::
Fog
::
Storage
.
new
(
fog_credentials
)
end
end
def
directory
def
directory
dir
=
if
@options
[
:fog_directory
].
is_a?
(
Proc
)
dir
=
if
@options
[
:fog_directory
].
respond_to?
(
:call
)
@options
[
:fog_directory
].
call
(
self
)
@options
[
:fog_directory
].
call
(
self
)
else
else
@options
[
:fog_directory
]
@options
[
:fog_directory
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment