Module: Poncho::Params::ClassMethods

Defined in:
lib/poncho/params.rb

Constant Summary collapse

VALIDATES_DEFAULT_KEYS =
[:resource, :type, :required, :format, :in, :not_in, :length]

Instance Method Summary collapse

Instance Method Details

#integer(name, options = {}) ⇒ Object



31
32
33
# File 'lib/poncho/params.rb', line 31

def integer(name, options = {})
  param(name, options.merge(:type => :integer))
end

#param(name, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/poncho/params.rb', line 14

def param(name, options = {})
  type  =  options[:type]
  type ||= options[:resource] ? :resource : :string

  klass = param_for_type(type)
  param = klass.new(name, options)
  params[param.name] = param

  create_validations_for(param)

  param
end

#paramsObject



10
11
12
# File 'lib/poncho/params.rb', line 10

def params
  @params ||= {}
end

#string(name, options = {}) ⇒ Object



27
28
29
# File 'lib/poncho/params.rb', line 27

def string(name, options = {})
  param(name, options.merge(:type => :string))
end