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
2d28dbca
Commit
2d28dbca
authored
Jan 25, 2013
by
Mike Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the attachment query to the HasAttachedFile class
parent
c555f517
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
4 deletions
+13
-4
lib/paperclip.rb
+0
-4
lib/paperclip/has_attached_file.rb
+9
-0
test/has_attached_file_test.rb
+4
-0
No files found.
lib/paperclip.rb
View file @
2d28dbca
...
...
@@ -192,10 +192,6 @@ module Paperclip
attachment
=
record
.
send
(
name
)
attachment
.
send
(
:flush_errors
)
end
define_method
"
#{
name
}
?"
do
send
(
name
).
file?
end
end
end
end
...
...
lib/paperclip/has_attached_file.rb
View file @
2d28dbca
...
...
@@ -13,6 +13,7 @@ module Paperclip
def
define
define_getter
define_setter
define_query
end
private
...
...
@@ -45,5 +46,13 @@ module Paperclip
send
(
name
).
assign
(
file
)
end
end
def
define_query
name
=
@name
@klass
.
send
:define_method
,
"
#{
@name
}
?"
do
send
(
name
).
file?
end
end
end
end
test/has_attached_file_test.rb
View file @
2d28dbca
...
...
@@ -10,6 +10,10 @@ class HasAttachedFileTest < Test::Unit::TestCase
should
'define a getter on the class object'
do
assert_adding_attachment
(
'avatar'
).
defines_method
(
'avatar'
)
end
should
'define a query on the class object'
do
assert_adding_attachment
(
'avatar'
).
defines_method
(
'avatar?'
)
end
end
private
...
...
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