Module: SimpleFormRecurringSelect::HasRecurrenceRule::ClassMethods

Defined in:
lib/simple_form_recurring_select/has_recurrence_rule.rb

Instance Method Summary collapse

Instance Method Details

#has_recurrence_rule(accessor_name = :recurrence_rule) ⇒ Object


10
11
12
13
14
15
16
17
18
19
# File 'lib/simple_form_recurring_select/has_recurrence_rule.rb', line 10

def has_recurrence_rule(accessor_name = :recurrence_rule)
  attr_reader accessor_name

  define_method "#{accessor_name}=" do |value|
    case value
    when NilClass, 'null' then nil
    else instance_variable_set "@#{accessor_name}", IceCube::Rule.from_hash(JSON.parse(value))
    end
  end
end