Sha256: 78d87cb896b1819f9ca2b6f56ddc0cae3db4e1023d25c05a4e3b5c9dc56484f6
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
module Traitorous module StandardProcs class << self NOOP = proc { |data| data } # a proc that simply passes through it's input as output def noop NOOP end # a proc that simply passes through it's input if the input is truthy, # otherwise it returns it's default value # @param default_value [Object] the default value to use with data is # falsey # @return [Object] returns data || default_value def default(default_value) proc { |data| data || default_value } end # This proc calls method_name on data. # @param method_name [Symbol, String] method to send data # @return [Object] result of calling method_name on data def call_on_self(method_name) proc { |data| data.send(method_name) } end # This proc calls klass with :with and passes data as params # @param klass [Class, Module, Object] obj to call # @param with_method: [Symbol, String] method to send klass with data as params def call_on(klass, with_method: :new) proc {|data| klass.send(with_method, data)} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
traitorous-0.6.1 | lib/traitorous/standard_procs.rb |