Module: IceCubeCron::ParserAttribute::ClassMethods

Defined in:
lib/ice_cube_cron/parser_attribute.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#parser_attribute_accessor(attr_name, &cleanser) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ice_cube_cron/parser_attribute.rb', line 12

def parser_attribute_accessor(attr_name, &cleanser)
  getter = attr_name.to_s.to_sym
  setter = "#{attr_name}=".to_sym

  define_method(getter) do
    expression_hash[getter]
  end

  define_method(setter) do |val|
    val = yield val if cleanser
    expression_hash[getter] = val
  end

  _define_parser_attribute_aliases(attr_name, getter, setter)
end