Class: FoggyBottom::Case
- Inherits:
-
Object
show all
- Includes:
- ActiveModel::AttributeMethods, ActiveModel::Dirty, ActiveModel::Serialization, FoggyBottom::Columns::Case
- Defined in:
- lib/foggy_bottom/case.rb
Constant Summary
FoggyBottom::Columns::Case::ALL_COLUMNS
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
included
Constructor Details
#initialize(attributes = {}) ⇒ Case
Returns a new instance of Case.
43
44
45
|
# File 'lib/foggy_bottom/case.rb', line 43
def initialize(attributes = {})
@attributes = attributes.stringify_keys
end
|
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
10
11
12
|
# File 'lib/foggy_bottom/case.rb', line 10
def api
@api
end
|
Class Method Details
.create_from_xml(xml, api) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/foggy_bottom/case.rb', line 27
def create_from_xml(xml, api)
new( {}.tap do |attributes|
(FoggyBottom::Columns::Case::ALL_COLUMNS - %w(tags)).each do |col|
attributes[col] = xml.at_css(col).content
end
attributes['tags'] = [].tap do |tags|
xml.css("tag").each {|t| tags << t.content }
end
end).tap do |instance|
instance.api = api
end
end
|
.find(case_id, api) ⇒ Object
15
16
17
18
19
|
# File 'lib/foggy_bottom/case.rb', line 15
def find( case_id, api )
details = api.exec(:search, :q => case_id, :cols => FoggyBottom::Columns::Case::ALL_COLUMNS.join(',') ).at_css("case")
create_from_xml(details, api) if details
end
|
.search(terms, api) ⇒ Object
21
22
23
24
25
|
# File 'lib/foggy_bottom/case.rb', line 21
def search( terms, api )
api.exec(:search, :q => terms, :cols => FoggyBottom::Columns::Case::ALL_COLUMNS.join(',')).css('case').collect do |details|
create_from_xml(details, api)
end
end
|
Instance Method Details
#attributes=(new_attributes) ⇒ Object
47
48
49
|
# File 'lib/foggy_bottom/case.rb', line 47
def attributes=(new_attributes)
new_attributes.each_pair {|k,v| send("#{k}=", v) }
end
|
#resolve(comment = nil) ⇒ Object
57
58
59
|
# File 'lib/foggy_bottom/case.rb', line 57
def resolve( = nil )
save!(, :resolve)
end
|
#save(comment = nil) ⇒ Object
51
52
53
54
55
|
# File 'lib/foggy_bottom/case.rb', line 51
def save( = nil )
return unless changed?
save!()
end
|
#to_s ⇒ Object
61
62
63
|
# File 'lib/foggy_bottom/case.rb', line 61
def to_s
"#{ixBug} - #{sTitle}"
end
|