Sha256: cf2117dcfb99f5a8d32501b28bd039bf2e00c2a5f4f6e6c3bf7da857d2f619fd

Contents?: true

Size: 949 Bytes

Versions: 17

Compression:

Stored size: 949 Bytes

Contents



module Antrapol
  module ToolRack
    module BlockParamsUtils
      include ConditionUtils

      def value_from_block(blockKey, defValue, opts = { }, &block)
        if block
          blockParams = nil
          if not_empty?(opts)
            blockParams = opts[:blockArgs]
          end

          value = nil
          if blockParams.nil?
            value = block.call(blockKey)
          else
            if blockParams.is_a?(Array)
              value = block.call(blockKey, *blockParams)
            else
              value = block.call(blockKey, blockParams)
            end
          end

          block.call(:inspect_given_value, blockKey, opts, value)

          value = defValue if is_empty?(value)

          value
        else
          defValue
        end
      end


      def self.included(klass)
        klass.class_eval <<-END
          extend Antrapol::ToolRack::BlockParamsUtils
        END
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
toolrack-0.24.3 lib/toolrack/block_params_utils.rb
toolrack-0.24.2 lib/toolrack/block_params_utils.rb
toolrack-0.24.1 lib/toolrack/block_params_utils.rb
toolrack-0.24.0 lib/toolrack/block_params_utils.rb
toolrack-0.23.3 lib/toolrack/block_params_utils.rb
toolrack-0.23.2 lib/toolrack/block_params_utils.rb
toolrack-0.22.1 lib/toolrack/block_params_utils.rb
toolrack-0.22.0 lib/toolrack/block_params_utils.rb
toolrack-0.21.0 lib/toolrack/block_params_utils.rb
toolrack-0.20.2 lib/toolrack/block_params_utils.rb
toolrack-0.20.1 lib/toolrack/block_params_utils.rb
toolrack-0.20.0 lib/toolrack/block_params_utils.rb
toolrack-0.19.1 lib/toolrack/block_params_utils.rb
toolrack-0.18.6 lib/toolrack/block_params_utils.rb
toolrack-0.18.5 lib/toolrack/block_params_utils.rb
toolrack-0.18.4 lib/toolrack/block_params_utils.rb
toolrack-0.18.3 lib/toolrack/block_params_utils.rb