Module: Skr::Concerns::LockedFields::InstanceMethods

Defined in:
lib/skr/concerns/locked_fields.rb

Instance Method Summary collapse

Instance Method Details

#unlock_fields(*flds, &block) ⇒ Object

Unlock the field for updates inside the block yields, then restores it. Is class wide, meaning it Will temporarily open all instances of the class up for access in a threaded environment



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/skr/concerns/locked_fields.rb', line 68

def unlock_fields( *flds, &block )
    attr_syms = flds.map(&:to_s)

    self.class.attr_readonly.subtract( attr_syms )

    yield

    attr_syms.each do | fld |
        self.class.attr_readonly.add( fld )
    end

end