Module: Traitorous::StandardProcs
- Defined in:
- lib/traitorous/standard_procs.rb
Constant Summary collapse
- NOOP =
proc { |data| data }
Class Method Summary collapse
-
.call_on(klass, with_method: :new) ⇒ Object
This proc calls klass with :with and passes data as params.
-
.call_on_self(method_name) ⇒ Object
This proc calls method_name on data.
-
.default(default_value) ⇒ Object
a proc that simply passes through it’s input if the input is truthy, otherwise it returns it’s default value.
-
.noop ⇒ Object
a proc that simply passes through it’s input as output.
Class Method Details
.call_on(klass, with_method: :new) ⇒ Object
This proc calls klass with :with and passes data as params
30 31 32 |
# File 'lib/traitorous/standard_procs.rb', line 30 def call_on(klass, with_method: :new) proc {|data| klass.send(with_method, data)} end |
.call_on_self(method_name) ⇒ Object
This proc calls method_name on data.
23 24 25 |
# File 'lib/traitorous/standard_procs.rb', line 23 def call_on_self(method_name) proc { |data| data.send(method_name) } end |
.default(default_value) ⇒ Object
a proc that simply passes through it’s input if the input is truthy,
otherwise it returns it's default value
16 17 18 |
# File 'lib/traitorous/standard_procs.rb', line 16 def default(default_value) proc { |data| data || default_value } end |
.noop ⇒ Object
a proc that simply passes through it’s input as output
7 8 9 |
# File 'lib/traitorous/standard_procs.rb', line 7 def noop NOOP end |