Browse Source

allow to default the flags field to flags

themage
theMage 5 years ago
parent
commit
deebf7f9e6
1 changed files with 15 additions and 0 deletions
  1. 15 0
      lib/oSMo/Db.pm

+ 15 - 0
lib/oSMo/Db.pm

@ -154,6 +154,11 @@ sub inserts {
154 154
sub is_flag_set {
155 155
	my ($self,$field,$flag) = @_;
156 156
157
  if (!$flag) {
158
    $flag = $field;
159
    $field = 'flags';
160
  }
161
157 162
	my $value = $self->$field();
158 163
	my %flags = map { $_ => undef } split /,/, $value;
159 164
@ -163,6 +168,11 @@ sub is_flag_set {
163 168
sub set_flags {
164 169
	my ($self,$field,@flags) = @_;
165 170
171
  if (!@flags) {
172
    @flags = $field;
173
    $field = 'flags';
174
  }
175
166 176
	my $value = $self->$field();
167 177
	my %flags = map { $_ => undef } split /,/, $value;
168 178
@ -177,6 +187,11 @@ sub set_flags {
177 187
sub unset_flags {
178 188
	my ($self,$field,@flags) = @_;
179 189
190
  if (!@flags) {
191
    @flags = $field;
192
    $field = 'flags';
193
  }
194
180 195
	my $value = $self->$field();
181 196
	my %flags = map { $_ => undef } split /,/, $value;
182 197