Class: Marshalsea::Marshal::Budget
- Inherits:
-
Object
- Object
- Marshalsea::Marshal::Budget
- Defined in:
- lib/marshalsea/marshal/limits.rb
Instance Method Summary collapse
- #class_name!(size) ⇒ Object
- #entries!(count) ⇒ Object
-
#initialize(limits) ⇒ Budget
constructor
A new instance of Budget.
- #instance_variables!(count) ⇒ Object
- #link! ⇒ Object
- #node! ⇒ Object
- #registered! ⇒ Object
- #scalar!(size) ⇒ Object
- #struct_members!(count) ⇒ Object
- #symbol! ⇒ Object
- #symbol_name!(size) ⇒ Object
- #symbol_reference! ⇒ Object
Constructor Details
#initialize(limits) ⇒ Budget
Returns a new instance of Budget.
100 101 102 103 104 105 106 107 108 |
# File 'lib/marshalsea/marshal/limits.rb', line 100 def initialize(limits) @limits = limits @nodes = 0 @registered = 0 @symbols = 0 @links = 0 @symbol_references = 0 @scalar_total = 0 end |
Instance Method Details
#class_name!(size) ⇒ Object
139 140 141 |
# File 'lib/marshalsea/marshal/limits.rb', line 139 def class_name!(size) check(size, limits.max_class_name_bytes, Limits::ROLE_CLASS_NAME) end |
#entries!(count) ⇒ Object
151 152 153 |
# File 'lib/marshalsea/marshal/limits.rb', line 151 def entries!(count) check(count, limits.max_collection_entries, Limits::ROLE_ENTRIES) end |
#instance_variables!(count) ⇒ Object
143 144 145 |
# File 'lib/marshalsea/marshal/limits.rb', line 143 def instance_variables!(count) check(count, limits.max_instance_variables, Limits::ROLE_INSTANCE_VARIABLES) end |
#link! ⇒ Object
125 126 127 128 |
# File 'lib/marshalsea/marshal/limits.rb', line 125 def link! @links += 1 check(@links, limits.max_object_links, Limits::ROLE_LINKS) end |
#node! ⇒ Object
110 111 112 113 |
# File 'lib/marshalsea/marshal/limits.rb', line 110 def node! @nodes += 1 check(@nodes, limits.max_nodes, Limits::ROLE_NODES) end |
#registered! ⇒ Object
115 116 117 118 |
# File 'lib/marshalsea/marshal/limits.rb', line 115 def registered! @registered += 1 check(@registered, limits.max_registered_objects, Limits::ROLE_REGISTERED) end |
#scalar!(size) ⇒ Object
155 156 157 158 159 |
# File 'lib/marshalsea/marshal/limits.rb', line 155 def scalar!(size) check(size, limits.max_scalar_bytes, Limits::ROLE_SCALAR) @scalar_total += size check(@scalar_total, limits.max_total_scalar_bytes, Limits::ROLE_TOTAL_SCALAR) end |
#struct_members!(count) ⇒ Object
147 148 149 |
# File 'lib/marshalsea/marshal/limits.rb', line 147 def struct_members!(count) check(count, limits.max_struct_members, Limits::ROLE_STRUCT_MEMBERS) end |
#symbol! ⇒ Object
120 121 122 123 |
# File 'lib/marshalsea/marshal/limits.rb', line 120 def symbol! @symbols += 1 check(@symbols, limits.max_symbol_definitions, Limits::ROLE_SYMBOLS) end |
#symbol_name!(size) ⇒ Object
135 136 137 |
# File 'lib/marshalsea/marshal/limits.rb', line 135 def symbol_name!(size) check(size, limits.max_symbol_name_bytes, Limits::ROLE_SYMBOL_NAME) end |
#symbol_reference! ⇒ Object
130 131 132 133 |
# File 'lib/marshalsea/marshal/limits.rb', line 130 def symbol_reference! @symbol_references += 1 check(@symbol_references, limits.max_symbol_references, Limits::ROLE_SYMBOL_REFERENCES) end |