Module: ActiveBugzilla::Bug::FlagsManagement

Extended by:
ActiveSupport::Concern
Included in:
ActiveBugzilla::Bug
Defined in:
lib/active_bugzilla/bug/flags_management.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#changed_attributes_with_flagsObject



70
71
72
73
74
# File 'lib/active_bugzilla/bug/flags_management.rb', line 70

def changed_attributes_with_flags
  changed_attributes = changed_attributes_without_flags
  changed_attributes['flags'] = flags_previous_value if flags.changed?
  changed_attributes
end

#changed_with_flags?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/active_bugzilla/bug/flags_management.rb', line 52

def changed_with_flags?
  changed_without_flags? || flags.changed?
end

#changes_with_flagsObject



56
57
58
59
60
# File 'lib/active_bugzilla/bug/flags_management.rb', line 56

def changes_with_flags
  changes = changes_without_flags
  changes['flags'] = [flags_previous_value, flags] if flags.changed?
  changes
end

#flag_objectsObject



17
18
19
# File 'lib/active_bugzilla/bug/flags_management.rb', line 17

def flag_objects
  @flag_objects ||= ActiveBugzilla::Flag.instantiate_from_raw_data(raw_flags, @id)
end

#flagsObject



26
27
28
29
30
31
32
33
34
# File 'lib/active_bugzilla/bug/flags_management.rb', line 26

def flags
  @flags ||= begin
    flags_hash = flag_objects.each_with_object(DirtyIndifferentHashy.new) do |flag, hash|
      hash[flag.name] = flag.status
    end
    flags_hash.clean_up!
    flags_hash
  end
end

#flags=(value) ⇒ Object



21
22
23
24
# File 'lib/active_bugzilla/bug/flags_management.rb', line 21

def flags=(value)
  flags_will_change! unless value == @flags
  @flags = value
end

#flags_previous_valueObject



62
63
64
65
66
67
68
# File 'lib/active_bugzilla/bug/flags_management.rb', line 62

def flags_previous_value
  previous_flags = flags.dup
  flags.changes.each do |key, value|
    previous_flags[key] = value.first
  end
  previous_flags
end

#flags_raw_updatesObject



36
37
38
39
40
41
42
43
44
# File 'lib/active_bugzilla/bug/flags_management.rb', line 36

def flags_raw_updates
  raw_updates = []
  flags.changes.each do |key, value|
    _old_status, new_status = value
    new_status ||= 'X'
    raw_updates << {'name' => key.to_s, "status" => new_status}
  end
  raw_updates
end

#reset_flagsObject



46
47
48
49
50
# File 'lib/active_bugzilla/bug/flags_management.rb', line 46

def reset_flags
  @flag_objects = nil
  @flags        = nil
  flags
end