Class: Police::Labels::UnsafeStream
- Inherits:
-
DataFlow::Label
- Object
- DataFlow::Label
- Police::Labels::UnsafeStream
- Defined in:
- lib/police/labels/unsafe_stream.rb
Overview
Adds a label to any data read from a IO stream.
Class Method Summary collapse
Instance Method Summary collapse
- #accepts?(data) ⇒ Boolean
-
#initialize(unsafe_label) ⇒ UnsafeStream
constructor
A new instance of UnsafeStream.
-
#read(return_value, receiver, *args) ⇒ Object
Adds a label to the read’s return value.
Constructor Details
#initialize(unsafe_label) ⇒ UnsafeStream
Returns a new instance of UnsafeStream.
9 10 11 |
# File 'lib/police/labels/unsafe_stream.rb', line 9 def initialize(unsafe_label) @label = unsafe_label end |
Class Method Details
.autoflow? ⇒ Boolean
14 15 16 |
# File 'lib/police/labels/unsafe_stream.rb', line 14 def self.autoflow? false end |
.return_hook(method_name) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/police/labels/unsafe_stream.rb', line 24 def self.return_hook(method_name) case method_name when :read :read else nil end end |
.yield_args_hook(method_name) ⇒ Object
34 35 36 |
# File 'lib/police/labels/unsafe_stream.rb', line 34 def self.yield_args_hook(method_name) nil end |
Instance Method Details
#accepts?(data) ⇒ Boolean
19 20 21 |
# File 'lib/police/labels/unsafe_stream.rb', line 19 def accepts?(data) data.kind_of?(IO) || data.kind_of?(StringIO) end |
#read(return_value, receiver, *args) ⇒ Object
Adds a label to the read’s return value.
40 41 42 |
# File 'lib/police/labels/unsafe_stream.rb', line 40 def read(return_value, receiver, *args) Police::DataFlow.label return_value, @label end |