Class: Symbol

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

Class Method Summary collapse

Class Method Details

.pattern(name, pattern, &formation) ⇒ Object



2
3
4
5
# File 'lib/core_ext.rb', line 2

def self.pattern(name, pattern, &formation)
  define_method(name) {to_s.match(pattern) ? self : formation.call(self).to_sym}
  define_method(name.question) {to_s.match(pattern)}
end