Class: ActiveBugzilla::Bug
Defined Under Namespace
Modules: FlagsManagement, ServiceManagement
Constant Summary
ServiceManagement::ATTRIBUTES_XMLRPC_RENAMES_MAP
Class Method Summary
collapse
Instance Method Summary
collapse
#changed_attributes_with_flags, #changed_with_flags?, #changes_with_flags, #flag_objects, #flags, #flags=, #flags_previous_value, #flags_raw_updates, #reset_flags
#attribute_names
Methods inherited from Base
service, service=
Constructor Details
#initialize(attributes = {}) ⇒ Bug
Returns a new instance of Bug.
16
17
18
19
20
21
22
|
# File 'lib/active_bugzilla/bug.rb', line 16
def initialize(attributes = {})
attributes.each do |key, value|
next unless attribute_names.include?(key)
ivar_key = "@#{key}"
instance_variable_set(ivar_key, value)
end if attributes
end
|
Class Method Details
.find(options = {}) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/active_bugzilla/bug.rb', line 73
def self.find(options = {})
options[:include_fields] ||= []
options[:include_fields] << :id unless options[:include_fields].include?(:id)
fields_to_include = options[:include_fields].dup
search(options).collect do |bug_hash|
fields_to_include.each do |field|
bug_hash[field] = nil unless bug_hash.key?(field)
bug_hash[field] = flags_from_raw_flags_data(bug_hash[field]) if field == :flags
end
Bug.new(bug_hash)
end
end
|
Instance Method Details
64
65
66
67
|
# File 'lib/active_bugzilla/bug.rb', line 64
def (, is_private = false)
= service.(@id, , :is_private => is_private)
reload
end
|
#reload ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/active_bugzilla/bug.rb', line 31
def reload
raw_reset
reset_instance_variables
reset_flags
@comments = Comment.instantiate_from_raw_data()
self
end
|
#save ⇒ Object
24
25
26
27
28
29
|
# File 'lib/active_bugzilla/bug.rb', line 24
def save
return if changes.empty?
update_attributes(changed_attribute_hash)
@changed_attributes.clear
reload
end
|
#update_attribute(key, value) ⇒ Object
56
57
58
|
# File 'lib/active_bugzilla/bug.rb', line 56
def update_attribute(key, value)
update_attributes(key => value)
end
|
#update_attributes(attributes) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/active_bugzilla/bug.rb', line 39
def update_attributes(attributes)
attributes.delete(:id)
attributes.each do |name, value|
symbolized_name = name.to_sym
raise "Unknown Attribute #{name}" unless attribute_names.include?(symbolized_name)
public_send("#{name}=", value)
if symbolized_name == :flags
attributes[name] = flags_raw_updates
else
@changed_attributes.delete(symbolized_name)
end
end
raw_update(attributes) unless attributes.empty?
end
|