Module: Streamlined::Helpers::TouchableProc

Defined in:
lib/streamlined/helpers.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#touchedObject

Returns the value of attribute touched.



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

def touched
  @touched
end

Class Method Details

.run_through_pipeline(in_context_binding, input, callback) ⇒ Object



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

def self.run_through_pipeline(in_context_binding, input, callback)
  Serbea::Pipeline.new(in_context_binding, input).tap { _1.instance_exec(&callback) }.then do |pipeline|
    -> { pipeline.value }
  end
end

Instance Method Details

#encodeObject



36
37
38
# File 'lib/streamlined/helpers.rb', line 36

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

#html_safeObject



21
22
23
24
# File 'lib/streamlined/helpers.rb', line 21

def html_safe
  @html_safe = true
  self
end

#html_safe?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/streamlined/helpers.rb', line 26

def html_safe?
  @html_safe == true
end

#to_sObject



30
31
32
33
34
# File 'lib/streamlined/helpers.rb', line 30

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

  super
end

#touchObject



16
17
18
19
# File 'lib/streamlined/helpers.rb', line 16

def touch
  self.touched = true
  self
end