Class: Poncho::Param

Inherits:
Object
  • Object
show all
Defined in:
lib/poncho/param.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Param

Returns a new instance of Param.



13
14
15
16
# File 'lib/poncho/param.rb', line 13

def initialize(name, options = {})
  @name    = name.to_sym
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



11
12
13
# File 'lib/poncho/param.rb', line 11

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/poncho/param.rb', line 11

def options
  @options
end

Class Method Details

.typeObject



3
4
5
6
7
8
9
# File 'lib/poncho/param.rb', line 3

def self.type
  @type ||= begin
    full_name = name.split('::').last
    full_name = full_name.gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
    full_name.sub(/_param$/, '').to_sym
  end
end

Instance Method Details

#convert(value) ⇒ Object



25
26
27
# File 'lib/poncho/param.rb', line 25

def convert(value)
  value
end

#typeObject



18
19
20
# File 'lib/poncho/param.rb', line 18

def type
  self.class.type
end

#validate_each(record, attribute, value) ⇒ Object



22
23
# File 'lib/poncho/param.rb', line 22

def validate_each(record, attribute, value)
end