Class: JsonRuleObject
- Inherits:
-
JsonRuleBase
- Object
- JsonRuleBase
- JsonRuleObject
- Defined in:
- lib/rules.rb
Instance Attribute Summary collapse
-
#allow_other_keys ⇒ Object
readonly
Returns the value of attribute allow_other_keys.
-
#key_rules ⇒ Object
readonly
Returns the value of attribute key_rules.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
Instance Method Summary collapse
- #add_key_rule(rule) ⇒ Object
- #disallow_other_keys ⇒ Object
-
#initialize ⇒ JsonRuleObject
constructor
A new instance of JsonRuleObject.
Constructor Details
#initialize ⇒ JsonRuleObject
Returns a new instance of JsonRuleObject.
9 10 11 12 13 |
# File 'lib/rules.rb', line 9 def initialize() @allow_other_keys = true @key_rules = [] @keys = [] end |
Instance Attribute Details
#allow_other_keys ⇒ Object (readonly)
Returns the value of attribute allow_other_keys.
7 8 9 |
# File 'lib/rules.rb', line 7 def allow_other_keys @allow_other_keys end |
#key_rules ⇒ Object (readonly)
Returns the value of attribute key_rules.
7 8 9 |
# File 'lib/rules.rb', line 7 def key_rules @key_rules end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
7 8 9 |
# File 'lib/rules.rb', line 7 def keys @keys end |
Instance Method Details
#add_key_rule(rule) ⇒ Object
20 21 22 23 24 |
# File 'lib/rules.rb', line 20 def add_key_rule(rule) @key_rules.push(rule) @keys.push(rule.key) self end |
#disallow_other_keys ⇒ Object
15 16 17 18 |
# File 'lib/rules.rb', line 15 def disallow_other_keys @allow_other_keys = false self end |