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
92e88fc3
Commit
92e88fc3
authored
Nov 21, 2012
by
Pavel Pravosud
Committed by
Jon Yurek
Nov 30, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a feature to evaluate lambdas for fog_file properties
parent
446a4cdb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletions
+31
-1
lib/paperclip/storage/fog.rb
+10
-1
test/storage/fog_test.rb
+21
-0
No files found.
lib/paperclip/storage/fog.rb
View file @
92e88fc3
...
@@ -66,7 +66,16 @@ module Paperclip
...
@@ -66,7 +66,16 @@ module Paperclip
end
end
def
fog_file
def
fog_file
@fog_file
||=
@options
[
:fog_file
]
||
{}
@fog_file
||=
begin
value
=
@options
[
:fog_file
]
if
!
value
{}
elsif
value
.
respond_to?
(
:call
)
value
.
call
(
self
)
else
value
end
end
end
end
def
fog_public
(
style
=
default_style
)
def
fog_public
(
style
=
default_style
)
...
...
test/storage/fog_test.rb
View file @
92e88fc3
...
@@ -90,6 +90,27 @@ class FogTest < Test::Unit::TestCase
...
@@ -90,6 +90,27 @@ class FogTest < Test::Unit::TestCase
end
end
end
end
context
"with file params provided as lambda"
do
setup
do
fog_file
=
lambda
{
|
a
|
{
:custom_header
=>
a
.
instance
.
custom_method
}}
klass
=
rebuild_model
:storage
=>
:fog
,
:fog_file
=>
fog_file
klass
.
class_eval
do
def
custom_method
'foobar'
end
end
@dummy
=
Dummy
.
new
end
should
"be able to evaluate correct values for file headers"
do
assert_equal
@dummy
.
avatar
.
send
(
:fog_file
),
{
:custom_header
=>
'foobar'
}
end
end
setup
do
setup
do
@fog_directory
=
'papercliptests'
@fog_directory
=
'papercliptests'
...
...
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