class SwaggerApi::Actions

Attributes

controller[RW]

Public Instance Methods

all!() click to toggle source
# File lib/swagger_api/actions.rb, line 12
def all!
  raise errors.full_messages unless valid?
  return only_actions unless only_actions.blank?
  defined_actions
end
defined_actions() click to toggle source
# File lib/swagger_api/actions.rb, line 18
def defined_actions
  restful_actions - except_actions
end
except_actions() click to toggle source
# File lib/swagger_api/actions.rb, line 26
def except_actions
  controller.actions.try(:except) || []
end
extra_actions() click to toggle source
# File lib/swagger_api/actions.rb, line 39
def extra_actions
  defined_actions - restful_actions
end
only_actions() click to toggle source
# File lib/swagger_api/actions.rb, line 22
def only_actions
  controller.actions.try(:only) || []
end
restful_actions() click to toggle source
# File lib/swagger_api/actions.rb, line 30
def restful_actions
  %w[index show create update delete]
end
validate_actions() click to toggle source
# File lib/swagger_api/actions.rb, line 34
def validate_actions
  errors.add(:base, "`actions` must include at least one of #{restful_actions}") if restful_actions.blank?
  errors.add(:base, "`actions` can only include one of #{restful_actions}. #{(defined_actions - restful_actions)} are not allowed") unless extra_actions.blank?
end