Sha256: d35563c0884b8f58f35d357f59004c514861c3868c87939fbf010906c968d8e7

Contents?: true

Size: 609 Bytes

Versions: 2

Compression:

Stored size: 609 Bytes

Contents

require 'parametric/params'
module Parametric
  module TypedParams
    def self.included(base)
      base.send(:include, Params)
      base.extend DSL
    end

    module DSL
      def integer(field_name, label = '', opts = {}, &block)
        param(field_name, label, opts.merge(coerce: :to_i), &block)
      end

      def string(field_name, label = '', opts = {}, &block)
        param(field_name, label, opts.merge(coerce: :to_s), &block)
      end

      def array(field_name, label = '', opts = {}, &block)
        param(field_name, label, opts.merge(multiple: true), &block)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
parametric-0.0.5 lib/parametric/typed_params.rb
parametric-0.0.4 lib/parametric/typed_params.rb