Class: Peaty::Story
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#attributes, #connection, #error
Class Method Summary collapse
- .collection_path(options = {}) ⇒ Object
- .element ⇒ Object
- .member_path(id, options = {}) ⇒ Object
- .move_path(id, options = {}) ⇒ Object
-
.releases(options = {}) ⇒ Object
Filters.
Instance Method Summary collapse
-
#estimate ⇒ Object
chores, bugs, releases may or may not have estimates.
-
#move(options) ⇒ Object
Moves a story before or after another story.
- #project ⇒ Object
- #story_type ⇒ Object (also: #type)
Methods inherited from Base
all, build, #error?, filter_options, find, find_by_id, first, #id, #initialize, #method_missing, #new_record?, parse, #respond_to?, #save, with_connection
Constructor Details
This class inherits a constructor from Peaty::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Peaty::Base
Class Method Details
.collection_path(options = {}) ⇒ Object
47 48 49 |
# File 'lib/peaty/story.rb', line 47 def collection_path( = {}) "/projects/%i/stories" % [:project_id].to_i end |
.element ⇒ Object
44 45 46 |
# File 'lib/peaty/story.rb', line 44 def element "story" end |
.member_path(id, options = {}) ⇒ Object
50 51 52 |
# File 'lib/peaty/story.rb', line 50 def member_path(id, = {}) "/projects/%i/stories/%i" % [[:project_id].to_i, id] end |
.move_path(id, options = {}) ⇒ Object
53 54 55 |
# File 'lib/peaty/story.rb', line 53 def move_path(id, = {}) "/projects/%i/stories/%i/moves?move[move]=%s&move[target]=%i" % [[:project_id].to_i, id, [:type], [:target_id].to_i] end |
.releases(options = {}) ⇒ Object
Filters
59 60 61 |
# File 'lib/peaty/story.rb', line 59 def releases( = {}) self.filter(:type => :release) end |
Instance Method Details
#estimate ⇒ Object
chores, bugs, releases may or may not have estimates
11 12 13 |
# File 'lib/peaty/story.rb', line 11 def estimate self.attributes["estimate"].to_i end |
#move(options) ⇒ Object
Moves a story before or after another story
story1.move(:before => story2)
story2.move(:after => story1)
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/peaty/story.rb', line 23 def move() @error = nil = { :project_id => project_id } if [:before] .merge!({ :type => :before, :target_id => [:before].id }) elsif [:after] .merge!({ :type => :after, :target_id => [:after].id }) else raise ArgumentError, "Must specify :before => story or :after => story" end self.connection[self.class.move_path(id, )].post("").body self rescue RestClient::UnprocessableEntity => e @error = JSON.parse(XmlToJson.transform(e.response.body))["message"] false end |
#project ⇒ Object
15 16 17 |
# File 'lib/peaty/story.rb', line 15 def project Project.with_connection(self.class.connection).find(self.project_id) end |
#story_type ⇒ Object Also known as: type
5 6 7 |
# File 'lib/peaty/story.rb', line 5 def story_type self.attributes["story_type"].to_sym if story_type? end |