Sha256: d8f86e1d48b290ff5928803944376aeb0614aa713c4a270558b35c32b9b9c96b

Contents?: true

Size: 683 Bytes

Versions: 49

Compression:

Stored size: 683 Bytes

Contents

class Story < Ticket
  has_one :story_detail, foreign_key: "ticket_id", dependent: :destroy

  validates :who, :what, presence: true

  after_save do 
    story_detail.save if story_detail.changed?
  end

  [:who, :what, :why].each do |method|
    define_method(method) do |*args|
      return nil unless story_detail
      story_detail.send(method, *args)
    end

    define_method("#{method}=") do |*args|
      build_story_detail unless story_detail
      story_detail.send("#{method}=", *args)
    end
  end

  def title
    return super unless who.present? && what.present?
    title = "#{who} wants to #{what}"
    title += ", so: #{why}" if why.present?

    title
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
tawork-0.0.29 app/models/story.rb
tawork-0.0.28 app/models/story.rb
tawork-0.0.27 app/models/story.rb
tawork-0.0.26 app/models/story.rb
tawork-0.0.25 app/models/story.rb
tawork-0.0.24 app/models/story.rb
tawork-0.0.23 app/models/story.rb
tawork-0.0.22 app/models/story.rb
tawork-0.0.21 app/models/story.rb
tawork-0.0.20 app/models/story.rb
tawork-0.0.19 app/models/story.rb
tawork-0.0.18 app/models/story.rb
tawork-0.0.17 app/models/story.rb
tawork-0.0.16 app/models/story.rb
tawork-0.0.15 app/models/story.rb
tawork-0.0.14 app/models/story.rb
tawork-0.0.13 app/models/story.rb
tawork-0.0.12 app/models/story.rb
tawork-0.0.11 app/models/story.rb
tawork-0.0.10 app/models/story.rb