Class: Datacaster::Runtimes::StructureCleaner
- Defined in:
- lib/datacaster/runtimes/structure_cleaner.rb
Instance Attribute Summary collapse
-
#checked_schema ⇒ Object
Returns the value of attribute checked_schema.
Attributes inherited from Base
Instance Method Summary collapse
-
#checked_key!(key) ⇒ Object
Array checked schema are the same as hash one, where instead of keys there are array indicies.
- #ignore_checks!(&block) ⇒ Object
-
#initialize ⇒ StructureCleaner
constructor
A new instance of StructureCleaner.
- #unchecked? ⇒ Boolean
- #will_check! ⇒ Object
Methods inherited from Base
#Failure, #Success, #after_call!, #before_call!, call, #inspect, #method_missing, not_found!, #respond_to_missing?, send_to_parent, #to_s
Constructor Details
#initialize ⇒ StructureCleaner
Returns a new instance of StructureCleaner.
6 7 8 9 10 11 12 13 14 |
# File 'lib/datacaster/runtimes/structure_cleaner.rb', line 6 def initialize(*) super @ignore = false @checked_schema = {} @should_check_stack = [false] @pointer_stack = [@checked_schema] @reserved_instance_variables += instance_variables end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Datacaster::Runtimes::Base
Instance Attribute Details
#checked_schema ⇒ Object
Returns the value of attribute checked_schema.
4 5 6 |
# File 'lib/datacaster/runtimes/structure_cleaner.rb', line 4 def checked_schema @checked_schema end |
Instance Method Details
#checked_key!(key) ⇒ Object
Array checked schema are the same as hash one, where instead of keys there are array indicies
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/datacaster/runtimes/structure_cleaner.rb', line 18 def checked_key!(key) if @ignore return yield if block_given? return end @pointer_stack.last[key] ||= {} @pointer_stack.push(@pointer_stack.last[key]) @should_check_stack.push(false) result = yield if block_given? was_checked = @should_check_stack.pop @pointer_stack.pop @pointer_stack.last[key] = true unless was_checked result end |
#ignore_checks!(&block) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/datacaster/runtimes/structure_cleaner.rb', line 38 def ignore_checks!(&block) @ignore = true result = yield @ignore = false result end |
#unchecked? ⇒ Boolean
45 46 47 |
# File 'lib/datacaster/runtimes/structure_cleaner.rb', line 45 def unchecked? @should_check_stack == [false] end |
#will_check! ⇒ Object
34 35 36 |
# File 'lib/datacaster/runtimes/structure_cleaner.rb', line 34 def will_check! @should_check_stack[-1] = true end |