Skip to content

Commit

Permalink
refactor(controller-actions-helper): use define_method with PERMITTED…
Browse files Browse the repository at this point in the history
…_ACTIONS
  • Loading branch information
difernandez committed Sep 25, 2020
1 parent f7460bd commit 85eeb14
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions lib/power_api/generator_helper/controller_actions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,8 @@ def controller_actions=(actions)
@controller_actions = actions.blank? ? PERMITTED_ACTIONS : actions & PERMITTED_ACTIONS
end

def index?
controller_actions.include?('index')
end

def create?
controller_actions.include?('create')
end

def show?
controller_actions.include?('show')
end

def update?
controller_actions.include?('update')
end

def destroy?
controller_actions.include?('destroy')
PERMITTED_ACTIONS.each do |action|
define_method("#{action}?") { controller_actions.include?(action) }
end

def resource_actions?
Expand Down

0 comments on commit 85eeb14

Please sign in to comment.