module StrongAttributes::Permissible
Public Instance Methods
permit!(*attribute_paths)
click to toggle source
Permits given attributes. May be invoked multiple times.
@example Each argument represents a single attribute:
ArticlePresenter.new(@article).permit(:heading, :article)
@example Attribute paths can be specified using symbol arrays. If an author name is normally accessed using @article.author.name:
ArticlePresenter.new(@article).permit([:author, :name])
@param [[Symbols*]*] attribute_paths
the attributes to permit. An array of symbols represents an attribute path.
@return [self]
# File lib/strong_attributes/permissible.rb, line 16 def permit! *attribute_paths permitted_attributes.permit *attribute_paths self end
permit_all!()
click to toggle source
Permits all presenter attributes for presents, present & filter methods.
# File lib/strong_attributes/permissible.rb, line 22 def permit_all! permitted_attributes.permit_all! self end
select_permitted(*attribute_paths)
click to toggle source
Selects the attributes given which have been permitted - an array of attributes @param [Array<Symbols>*] attribute_paths
the attribute paths to check. The attribute paths may also have arguments.
@return [Array<Array<Symbol>>] attribute (paths)
# File lib/strong_attributes/permissible.rb, line 31 def select_permitted *attribute_paths permitted_attributes.select_permitted *attribute_paths end
Protected Instance Methods
link_permissions(parent, relative_path = [])
click to toggle source
Links permissions to that of the parent. @param [Permissible] parent @param [Array<Symbol>] relative_path
The prefix prepended before every permission check relative to parent.
# File lib/strong_attributes/permissible.rb, line 44 def link_permissions parent, relative_path = [] @permitted_attributes = StrongAttributes::Permissions.new(parent.permitted_attributes, relative_path) end
permitted_attributes()
click to toggle source
# File lib/strong_attributes/permissible.rb, line 36 def permitted_attributes @permitted_attributes ||= StrongAttributes::Permissions.new end