Module: Releaf::ActionController::Features
- Extended by:
- ActiveSupport::Concern
- Included in:
- Releaf::ActionController
- Defined in:
- app/lib/releaf/action_controller/features.rb
Instance Method Summary collapse
- #action_feature(action) ⇒ Object
- #action_features ⇒ Object
- #feature_available?(feature) ⇒ Boolean
- #feature_disabled(exception) ⇒ Object
- #features ⇒ Object
- #verify_feature_availability! ⇒ Object
Instance Method Details
#action_feature(action) ⇒ Object
15 16 17 |
# File 'app/lib/releaf/action_controller/features.rb', line 15 def action_feature(action) action_features[action.to_sym] end |
#action_features ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/lib/releaf/action_controller/features.rb', line 23 def action_features { index: :index, new: :create, create: :create, show: (feature_available?(:show) ? :show : :edit), edit: :edit, update: :edit, confirm_destroy: :destroy, destroy: :destroy } end |
#feature_available?(feature) ⇒ Boolean
41 42 43 44 45 46 |
# File 'app/lib/releaf/action_controller/features.rb', line 41 def feature_available?(feature) return false if feature.blank? return false if feature == :create_another && !feature_available?(:create) return false if feature == :search && !feature_available?(:index) features.include? feature end |
#feature_disabled(exception) ⇒ Object
36 37 38 39 |
# File 'app/lib/releaf/action_controller/features.rb', line 36 def feature_disabled(exception) @feature = exception. respond_with(nil, responder: action_responder(:feature_disabled)) end |
#features ⇒ Object
19 20 21 |
# File 'app/lib/releaf/action_controller/features.rb', line 19 def features [:edit, :create, :create_another, :destroy, :index, :toolbox, :search] end |
#verify_feature_availability! ⇒ Object
10 11 12 13 |
# File 'app/lib/releaf/action_controller/features.rb', line 10 def verify_feature_availability! feature = action_feature(params[:action]) raise Releaf::FeatureDisabled, feature.to_s if feature.present? && !feature_available?(feature) end |