Skip to content

Commit 104fbe9

Browse files
authored
Merge pull request #613 from headius/expose_load_settings
Expose load settings
2 parents ccf3b07 + 5b5d945 commit 104fbe9

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

ext/java/org/jruby/ext/psych/PsychParser.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.jcodings.unicode.UnicodeEncoding;
3535
import org.jruby.Ruby;
3636
import org.jruby.RubyArray;
37+
import org.jruby.RubyBoolean;
3738
import org.jruby.RubyClass;
3839
import org.jruby.RubyEncoding;
3940
import org.jruby.RubyFixnum;
@@ -514,6 +515,54 @@ public IRubyObject mark(ThreadContext context) {
514515
);
515516
}
516517

518+
@JRubyMethod(name = "max_aliases_for_collections=")
519+
public IRubyObject max_aliases_for_collections_set(IRubyObject max) {
520+
loadSettingsBuilder.setMaxAliasesForCollections(max.convertToInteger().getIntValue());
521+
522+
return max;
523+
}
524+
525+
@JRubyMethod(name = "max_aliases_for_collections")
526+
public IRubyObject max_aliases_for_collections(ThreadContext context) {
527+
return context.runtime.newFixnum(buildSettings().getMaxAliasesForCollections());
528+
}
529+
530+
@JRubyMethod(name = "allow_duplicate_keys=")
531+
public IRubyObject allow_duplicate_keys_set(IRubyObject allow) {
532+
loadSettingsBuilder.setAllowDuplicateKeys(allow.isTrue());
533+
534+
return allow;
535+
}
536+
537+
@JRubyMethod(name = "allow_duplicate_keys")
538+
public IRubyObject allow_duplicate_keys(ThreadContext context) {
539+
return RubyBoolean.newBoolean(context, buildSettings().getAllowDuplicateKeys());
540+
}
541+
542+
@JRubyMethod(name = "allow_recursive_keys=")
543+
public IRubyObject allow_recursive_keys_set(IRubyObject allow) {
544+
loadSettingsBuilder.setAllowRecursiveKeys(allow.isTrue());
545+
546+
return allow;
547+
}
548+
549+
@JRubyMethod(name = "allow_recursive_keys")
550+
public IRubyObject allow_recursive_keys(ThreadContext context) {
551+
return RubyBoolean.newBoolean(context, buildSettings().getAllowRecursiveKeys());
552+
}
553+
554+
@JRubyMethod(name = "code_point_limit=")
555+
public IRubyObject code_point_limit_set(IRubyObject limit) {
556+
loadSettingsBuilder.setCodePointLimit(limit.convertToInteger().getIntValue());
557+
558+
return limit;
559+
}
560+
561+
@JRubyMethod(name = "code_point_limit")
562+
public IRubyObject code_point_limit(ThreadContext context) {
563+
return context.runtime.newFixnum(buildSettings().getCodePointLimit());
564+
}
565+
517566
private LoadSettings buildSettings() {
518567
return loadSettingsBuilder.build();
519568
}

0 commit comments

Comments
 (0)