Sha256: ed39fa4d12b3d4fa7ca31252fabe06b5bd2dd72be9cee1092ad8d2b17f9120e2
Contents?: true
Size: 671 Bytes
Versions: 1
Compression:
Stored size: 671 Bytes
Contents
# -*- encoding : utf-8 -*- module Mongoid module Toggle extend ActiveSupport::Concern autoload :Version, 'mongoid/toggle/version' included do def toggle!(field_name) process_toggle(field_name) save end def toggle(field_name) process_toggle(field_name) true end protected def process_toggle(field_name) field_definition = self.class.fields[field_name.to_s] return false if field_definition.nil? return false unless field_definition.type.to_s == 'Boolean' write_attribute(field_name, !read_attribute(field_name)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid_toggle-0.1.1 | lib/mongoid/toggle.rb |