Module: Action
- Defined in:
- lib/action.rb
Overview
The Action module is just a simple interface for the Bug class. Use this instead of using the Bug class directly, it should satisfy all actions needed to CRUD from the bugs database.
Class Method Summary collapse
-
.append_description(hash) ⇒ Object
Adds a new description to an existing bug.
-
.close_bug(hash) ⇒ Object
Closes the bug from being listed.
-
.delete_bug(hash) ⇒ Object
Delets the bug with the given id/name and associated bug descriptions.
-
.list_areas(*args) ⇒ Object
Returns all of the areas for the open bugs.
-
.list_bugs(hash = Hash.new) ⇒ Object
Lists all of the open bugs by whatever conditions are meant The intersection of the conditions are returned By default, status is false.
-
.list_names(*args) ⇒ Object
Returns all of the names of the open bugs.
-
.new_bug(hash) ⇒ Object
Takes a hash as a parameter which is the data for the bug.
-
.open_bug(hash) ⇒ Object
Opens a bug to be listed.
-
.update_bug(hash) ⇒ Object
Updates the given bug with new information.
Class Method Details
.append_description(hash) ⇒ Object
Adds a new description to an existing bug. Used when a user wants to add new information found about a bug. Takes a hash as parameter where one item is either :name or :id and the other is :description
7 8 9 10 11 |
# File 'lib/action.rb', line 7 def self.append_description(hash) return nil if hash[:description] =~ /^\s*$/ # Returns nil if no description given bug = Bug.search(hash) bug.bug_descriptions.create(:description => hash[:description]) end |
.close_bug(hash) ⇒ Object
Closes the bug from being listed.
14 15 16 17 |
# File 'lib/action.rb', line 14 def self.close_bug(hash) bug = Bug.search(hash) bug.update_attributes(:status => true) end |
.delete_bug(hash) ⇒ Object
Delets the bug with the given id/name and associated bug descriptions
20 21 22 23 |
# File 'lib/action.rb', line 20 def self.delete_bug(hash) bug = Bug.search(hash) bug.destroy end |
.list_areas(*args) ⇒ Object
Returns all of the areas for the open bugs
60 61 62 63 64 65 66 67 |
# File 'lib/action.rb', line 60 def self.list_areas(*args) # Find all open bugs bugs = list_bugs(*args) # Get all of the unique areas from the bugs areas = bugs.collect { |bug| bug.area } return areas.uniq end |
.list_bugs(hash = Hash.new) ⇒ Object
Lists all of the open bugs by whatever conditions are meant The intersection of the conditions are returned By default, status is false
28 29 30 31 32 |
# File 'lib/action.rb', line 28 def self.list_bugs(hash = Hash.new) hash[:status] = false unless hash.has_key?(:status) bugs = Bug.find(:all, :conditions => Helper::hash_to_sql(hash), :order => "priority DESC, date_time") return bugs end |
.list_names(*args) ⇒ Object
Returns all of the names of the open bugs
70 71 72 73 74 75 76 77 |
# File 'lib/action.rb', line 70 def self.list_names(*args) # Find all open bugs bugs = list_bugs(*args) # Get all of the uniqe names from the bugs names = bugs.collect { |bug| bug.name } return names.uniq end |
.new_bug(hash) ⇒ Object
Takes a hash as a parameter which is the data for the bug.
* name - Descriptive name used for searching
* priority - an integer, 1 being the highest priority, as large a number as you want.
* area - Area, can be the filename, classname, or programmer name, etc.
* description - Quick description, what was expected, what actually happened, and how to reproduce the bug.
39 40 41 42 43 44 45 |
# File 'lib/action.rb', line 39 def self.new_bug(hash) description = hash[:description] hash.delete(:description) bug = Bug.create(hash) bug.bug_descriptions.create(:description => description) return bug end |