Sha256: dec312720e74d8f5796c69fb207c868c100c8882b680bea9a96f298772ab1f34

Contents?: true

Size: 777 Bytes

Versions: 3

Compression:

Stored size: 777 Bytes

Contents

# frozen_string_literal: true

class Tramway::Page::PageDecorator < ::Tramway::Core::ApplicationDecorator
  class << self
    def collections
      [:all]
    end

    def show_associations
      [:blocks]
    end
    delegate :human_view_state_event_name, to: :model_class
  end

  delegate :title, to: :object

  decorate_association :blocks, state_machines: [:view_state]

  def lead
    object.body.first 200
  end

  def link
    Tramway::Page::Engine.routes.url_helpers.page_path slug: object.slug
  end

  def public_path
    if object.published?
      Tramway::Page::Engine.routes.url_helpers.page_path slug: object.slug
    end
  end

  def view_state_button_color(event)
    case event
    when :publish
      :success
    when :hide
      :default
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tramway-page-1.5.2.2 app/decorators/tramway/page/page_decorator.rb
tramway-page-1.5.2.1 app/decorators/tramway/page/page_decorator.rb
tramway-page-1.5.2 app/decorators/tramway/page/page_decorator.rb