Module: RuneRb::IO::Validation
- Extended by:
- Utils::Logging
- Defined in:
- lib/rrb/io/validation.rb
Overview
A module used for validating data operations performed on buffer objects.
Constant Summary
Constants included from Utils::Logging
Class Method Summary collapse
-
.from_io(io, length, buffer) ⇒ Object
Reads data directly from an IO stream.
-
.validate(buffer, operation, params = {}) ⇒ Object
Validates the passed parameters according to the options.
Methods included from Utils::Logging
class_name, err, err!, log, log!
Class Method Details
.from_io(io, length, buffer) ⇒ Object
Reads data directly from an IO stream.
27 28 29 30 31 |
# File 'lib/rrb/io/validation.rb', line 27 def from_io(io, length, buffer) raise 'Closed IO' if io.closed? io.read_nonblock(length, buffer.data) end |
.validate(buffer, operation, params = {}) ⇒ Object
TODO:
implement a ValidationError type to be raised when a validation fails.
Validates the passed parameters according to the options.
14 15 16 17 18 19 20 21 |
# File 'lib/rrb/io/validation.rb', line 14 def validate(buffer, operation, params = {}) return false unless valid_mode?(buffer, operation) return false if buffer.mode.include?('w') && params[:bit_access] && !valid_access?(buffer, params[:bit_access]) return false if params[:mutation] && !valid_mutation?(params[:mutation]) return false if params[:order] && !valid_order?(params[:order]) true end |