Skip to content

Commit

Permalink
Fix jruby being epically weird
Browse files Browse the repository at this point in the history
Need to submit this as a bug to jruby
  • Loading branch information
albus522 committed Dec 28, 2017
1 parent 8c63e48 commit 0779207
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/delayed/psych_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def visit_Psych_Nodes_Mapping(object) # rubocop:disable CyclomaticComplexity, Me
case object.tag
when %r{^!ruby/object}
result = super
if defined?(ActiveRecord::Base) && result.is_a?(ActiveRecord::Base)
if jruby_is_seriously_borked && result.is_a?(ActiveRecord::Base)
klass = result.class
id = result[klass.primary_key]
begin
Expand Down Expand Up @@ -78,6 +78,12 @@ def visit_Psych_Nodes_Mapping(object) # rubocop:disable CyclomaticComplexity, Me
end
end

# defined? is triggering something really messed up
# in jruby causing the AST to do some crazy things
def jruby_is_seriously_borked
defined?(ActiveRecord::Base)
end

def resolve_class(klass_name)
return nil if !klass_name || klass_name.empty?
klass_name.constantize
Expand Down

0 comments on commit 0779207

Please sign in to comment.