Sha256: 5d32fbb43b0f38dd02816ab6b8784ed54e84840cf78ac6e3db0cb78427996597

Contents?: true

Size: 529 Bytes

Versions: 1

Compression:

Stored size: 529 Bytes

Contents

class PostDecorator < Draper::Decorator
  # need to delegate id and new_record? for AR::Base#== (Rails 3.0 only)
  delegate :id, :new_record?

  def posted_date
    if source.created_at.to_date == DateTime.now.utc.to_date
      "Today"
    else
      "Not Today"
    end
  end

  def path_with_model
    h.post_path(source)
  end

  def path_with_id
    h.post_path(id: id)
  end

  def url_with_model
    h.post_url(source)
  end

  def url_with_id
    h.post_url(id: id)
  end

  def link
    h.link_to id.to_s, self
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
draper-1.0.0 spec/dummy/app/decorators/post_decorator.rb