Sha256: 06e7bc2e3389d8c90c14d14bb8fd0f3eac5fe271b063e5a748888320cfef9a78

Contents?: true

Size: 481 Bytes

Versions: 10

Compression:

Stored size: 481 Bytes

Contents

module Tenon
  class ApplicationDecorator < Draper::Decorator
    delegate_all

    def serializer_class
      "#{object.class}Serializer".safe_constantize
    end

    def path
      h.url_for(object)
    end

    def edit_path
      h.url_for([:edit, object])
    end

    def published?
      if object.try(:publish_at)
        object.publish_at <= Time.now
      elsif object.respond_to?(:published)
        object.published
      else
        true
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tenon-2.1.0 app/decorators/tenon/application_decorator.rb
tenon-2.0.8 app/decorators/tenon/application_decorator.rb
tenon-2.0.7 app/decorators/tenon/application_decorator.rb
tenon-2.0.6 app/decorators/tenon/application_decorator.rb
tenon-2.0.5 app/decorators/tenon/application_decorator.rb
tenon-2.0.4 app/decorators/tenon/application_decorator.rb
tenon-2.0.3 app/decorators/tenon/application_decorator.rb
tenon-2.0.2 app/decorators/tenon/application_decorator.rb
tenon-2.0.1 app/decorators/tenon/application_decorator.rb
tenon-2.0.0 app/decorators/tenon/application_decorator.rb