Module: Pundit::ExpectedAttributeValues::Policy
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/pundit/expected_attribute_values/policy.rb
Instance Method Summary collapse
- #expected_attribute_values_for_action(action_name) ⇒ Object
- #pundit_expected_attribute_values_for_attribute(attribute, action:) ⇒ Object
Instance Method Details
#expected_attribute_values_for_action(action_name) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/pundit/expected_attribute_values/policy.rb', line 8 def expected_attribute_values_for_action(action_name) action_method = "expected_attribute_values_for_#{action_name}" if respond_to?(action_method, true) public_send(action_method) || {} elsif respond_to?(:expected_attribute_values, true) expected_attribute_values || {} else {} end end |
#pundit_expected_attribute_values_for_attribute(attribute, action:) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/pundit/expected_attribute_values/policy.rb', line 19 def pundit_expected_attribute_values_for_attribute(attribute, action:) raise ArgumentError, "action is required" if action.nil? hash = expected_attribute_values_for_action(action.to_s) source = hash[attribute.to_sym] || hash[attribute.to_s] return [] unless source ValueResolver.normalize_list(ValueResolver.resolve(source, self)) end |