lib/flag_shih_tzu.rb
# returns true if successful
# third parameter allows you to specify that `self` should also have its in-memory flag attribute updated.
returns true if successful
third parameter allows you to specify that `self` should also have its in-memory flag attribute updated.
returns true if successful third parameter allows you to specify that ` self ` should also have its in - memory flag attribute updated .
def update_flag!(flag, value, update_instance = false)
    truthy = FlagShihTzu::TRUE_VALUES.include?(value)
    sql = self.class.set_flag_sql(flag.to_sym, truthy)
    if update_instance
      if truthy
        self.enable_flag(flag)
      else
        self.disable_flag(flag)
      end
    end
    if (ActiveRecord::VERSION::MAJOR <= 3)
      self.class.update_all(sql, self.class.primary_key => id) == 1
    else
      self.class.where("#{self.class.primary_key} = ?", id).update_all(sql) == 1
    end
  end
def update_flag! ( flag , value , update_instance = false ) truthy = FlagShihTzu :: TRUE_VALUES . include? ( value ) sql = self . class . set_flag_sql ( flag . to_sym , truthy ) if update_instance if truthy self . enable_flag ( flag ) else self . disable_flag ( flag ) end end if ( ActiveRecord :: VERSION :: MAJOR <= 3 ) self . class . update_all ( sql , self . class . primary_key => id ) == 1 else self . class . where ( "#{self.class.primary_key} = ?" , id ) . update_all ( sql ) == 1 end end
returns true if successful
third parameter allows you to specify that `self` should also have its in-memory flag attribute updated.
returns true if successful third parameter allows you to specify that ` self ` should also have its in - memory flag attribute updated .
flag
<not_specific>
value
<not_specific>
update_instance
<not_specific>