Commit 36a91fef by Kylan McBride Committed by Jon Yurek

Callbacks: Added Rails 4.1+ terminator conditional

parent 44df8639
...@@ -17,6 +17,7 @@ gemfile: ...@@ -17,6 +17,7 @@ gemfile:
- gemfiles/3.1.gemfile - gemfiles/3.1.gemfile
- gemfiles/3.2.gemfile - gemfiles/3.2.gemfile
- gemfiles/4.0.gemfile - gemfiles/4.0.gemfile
- gemfiles/4.1.gemfile
matrix: matrix:
allow_failures: allow_failures:
...@@ -26,3 +27,5 @@ matrix: ...@@ -26,3 +27,5 @@ matrix:
exclude: exclude:
- rvm: 1.9.2 - rvm: 1.9.2
gemfile: gemfiles/4.0.gemfile gemfile: gemfiles/4.0.gemfile
- rvm: 1.9.2
gemfile: gemfiles/4.1.gemfile
...@@ -17,3 +17,8 @@ appraise "4.0" do ...@@ -17,3 +17,8 @@ appraise "4.0" do
gem "rails", "~> 4.0.0" gem "rails", "~> 4.0.0"
gem "paperclip", :path => "../" gem "paperclip", :path => "../"
end end
appraise "4.1" do
gem "rails", "~> 4.1.0.beta"
gem "paperclip", :path => "../"
end
# This file was generated by Appraisal
source "https://rubygems.org"
gem "jruby-openssl", :platform=>:jruby
gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
gem "sqlite3", :platform=>:ruby
gem "rails", "~> 4.1.0.beta"
gem "paperclip", :path=>"../"
gemspec :path=>"../"
...@@ -7,7 +7,7 @@ module Paperclip ...@@ -7,7 +7,7 @@ module Paperclip
module Defining module Defining
def define_paperclip_callbacks(*callbacks) def define_paperclip_callbacks(*callbacks)
define_callbacks *[callbacks, {terminator: -> (target, result) {result == false}}].flatten define_callbacks *[callbacks, {:terminator => callback_terminator}].flatten
callbacks.each do |callback| callbacks.each do |callback|
eval <<-end_callbacks eval <<-end_callbacks
def before_#{callback}(*args, &blk) def before_#{callback}(*args, &blk)
...@@ -19,6 +19,16 @@ module Paperclip ...@@ -19,6 +19,16 @@ module Paperclip
end_callbacks end_callbacks
end end
end end
private
def callback_terminator
if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new('4.1.0.beta')
lambda { |target, result| result == false }
else
'result == false'
end
end
end end
module Running module Running
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment