Module: Streamlined::Helpers::PipeableProc

Includes:
Serbea::Pipeline::Helper
Defined in:
lib/streamlined/helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pipe_blockObject

Returns the value of attribute pipe_block.



8
9
10
# File 'lib/streamlined/helpers.rb', line 8

def pipe_block
  @pipe_block
end

#touchedObject

Returns the value of attribute touched.



8
9
10
# File 'lib/streamlined/helpers.rb', line 8

def touched
  @touched
end

Instance Method Details

#encodeObject



34
35
36
# File 'lib/streamlined/helpers.rb', line 34

def encode(...)
  to_s.encode(...)
end

#html_safeObject



19
20
21
22
# File 'lib/streamlined/helpers.rb', line 19

def html_safe
  @html_safe = true
  self
end

#html_safe?Boolean



24
25
26
# File 'lib/streamlined/helpers.rb', line 24

def html_safe?
  @html_safe == true
end

#pipe(&block) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/streamlined/helpers.rb', line 10

def pipe(&block)
  return super(self.(), &pipe_block) if pipe_block && !block

  self.touched = true
  return self unless block

  tap { _1.pipe_block = block }
end

#to_sObject



28
29
30
31
32
# File 'lib/streamlined/helpers.rb', line 28

def to_s
  return self.().to_s.then { html_safe? ? _1.html_safe : _1 } if touched

  super
end