consul/consul

View on GitHub
app/components/admin/budget_phases/toggle_enabled_component.rb

Summary

Maintainability
A
0 mins
Test Coverage
class Admin::BudgetPhases::ToggleEnabledComponent < ApplicationComponent
  attr_reader :phase
  delegate :enabled?, to: :phase

  def initialize(phase)
    @phase = phase
  end

  private

    def options
      { "aria-label": t("admin.budgets.edit.enable_phase", phase: phase.name) }
    end

    def action
      if enabled?
        :disable
      else
        :enable
      end
    end
end