Class: Artisan::Stories::StoryExporter
- Inherits:
-
Object
- Object
- Artisan::Stories::StoryExporter
- Defined in:
- lib/artisan/stories/story_exporter.rb
Instance Method Summary collapse
- #as_json(story_json = {}, options = {}) ⇒ Object
-
#initialize(story) ⇒ StoryExporter
constructor
A new instance of StoryExporter.
Constructor Details
#initialize(story) ⇒ StoryExporter
Returns a new instance of StoryExporter.
5 6 7 |
# File 'lib/artisan/stories/story_exporter.rb', line 5 def initialize(story) @story = story end |
Instance Method Details
#as_json(story_json = {}, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/artisan/stories/story_exporter.rb', line 9 def as_json(story_json = {}, ={}) = {} unless = neglect_created_at() story_json = story_json if @story.assigned_user story_json["assigned_user"] = { "full_name" => @story.assigned_user.full_name, "gravatar_url" => @story.assigned_user.gravatar_url } end story_json["assigned_user_options"] = @story.project.users.inject({}) do |collection, user| collection[user.full_name] = user.id collection end if @story.project story_json["created_at"] = @story.created_at.strftime("%m/%d/%Y") if !@story.created_at.nil? story_json["creator"] = @story.creator.full_name if @story.creator story_json["tag_list"] = @story.tag_list.join(",") story_json end |