Skip to content

Commit

Permalink
Merge pull request #613 from headius/expose_load_settings
Browse files Browse the repository at this point in the history
Expose load settings
  • Loading branch information
headius authored Feb 6, 2023
2 parents ccf3b07 + 5b5d945 commit 104fbe9
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions ext/java/org/jruby/ext/psych/PsychParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.jcodings.unicode.UnicodeEncoding;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyBoolean;
import org.jruby.RubyClass;
import org.jruby.RubyEncoding;
import org.jruby.RubyFixnum;
Expand Down Expand Up @@ -514,6 +515,54 @@ public IRubyObject mark(ThreadContext context) {
);
}

@JRubyMethod(name = "max_aliases_for_collections=")
public IRubyObject max_aliases_for_collections_set(IRubyObject max) {
loadSettingsBuilder.setMaxAliasesForCollections(max.convertToInteger().getIntValue());

return max;
}

@JRubyMethod(name = "max_aliases_for_collections")
public IRubyObject max_aliases_for_collections(ThreadContext context) {
return context.runtime.newFixnum(buildSettings().getMaxAliasesForCollections());
}

@JRubyMethod(name = "allow_duplicate_keys=")
public IRubyObject allow_duplicate_keys_set(IRubyObject allow) {
loadSettingsBuilder.setAllowDuplicateKeys(allow.isTrue());

return allow;
}

@JRubyMethod(name = "allow_duplicate_keys")
public IRubyObject allow_duplicate_keys(ThreadContext context) {
return RubyBoolean.newBoolean(context, buildSettings().getAllowDuplicateKeys());
}

@JRubyMethod(name = "allow_recursive_keys=")
public IRubyObject allow_recursive_keys_set(IRubyObject allow) {
loadSettingsBuilder.setAllowRecursiveKeys(allow.isTrue());

return allow;
}

@JRubyMethod(name = "allow_recursive_keys")
public IRubyObject allow_recursive_keys(ThreadContext context) {
return RubyBoolean.newBoolean(context, buildSettings().getAllowRecursiveKeys());
}

@JRubyMethod(name = "code_point_limit=")
public IRubyObject code_point_limit_set(IRubyObject limit) {
loadSettingsBuilder.setCodePointLimit(limit.convertToInteger().getIntValue());

return limit;
}

@JRubyMethod(name = "code_point_limit")
public IRubyObject code_point_limit(ThreadContext context) {
return context.runtime.newFixnum(buildSettings().getCodePointLimit());
}

private LoadSettings buildSettings() {
return loadSettingsBuilder.build();
}
Expand Down

0 comments on commit 104fbe9

Please sign in to comment.