Commit 36a91fef by Kylan McBride Committed by Jon Yurek

Callbacks: Added Rails 4.1+ terminator conditional

parent 44df8639
......@@ -17,6 +17,7 @@ gemfile:
- gemfiles/3.1.gemfile
- gemfiles/3.2.gemfile
- gemfiles/4.0.gemfile
- gemfiles/4.1.gemfile
matrix:
allow_failures:
......@@ -26,3 +27,5 @@ matrix:
exclude:
- rvm: 1.9.2
gemfile: gemfiles/4.0.gemfile
- rvm: 1.9.2
gemfile: gemfiles/4.1.gemfile
......@@ -17,3 +17,8 @@ appraise "4.0" do
gem "rails", "~> 4.0.0"
gem "paperclip", :path => "../"
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
module Defining
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|
eval <<-end_callbacks
def before_#{callback}(*args, &blk)
......@@ -19,6 +19,16 @@ module Paperclip
end_callbacks
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
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