lib/azeroth/resourceable/class_methods.rb in azeroth-0.6.5 vs lib/azeroth/resourceable/class_methods.rb in azeroth-0.7.0
- old
+ new
@@ -7,23 +7,16 @@
#
# Class methods added by {Resourceable}
module ClassMethods
# Adds resource methods for resource
#
- # @param name [String, Symbol] Name of the resource
- # @param options [Hash] resource building options
- # @option options only [Array<Symbol,String>] List of
- # actions to be built
- # @option options except [Array<Symbol,String>] List of
- # actions to not to be built
- # @option options decorator [Azeroth::Decorator,TrueClass,FalseClass]
- # Decorator class or flag allowing/disallowing decorators
+ # @param (see Resourceable.resource_for)
+ # @option (see Resourceable.resource_for)
+ # @return (see Resourceable.resource_for)
#
- # @return [Array<MethodDefinition>] list of methods created
+ # @see (see Resourceable.resource_for)
#
- # @see Options
- #
# @example Controller without delete
# class DocumentsController < ApplicationController
# include Azeroth::Resourceable
#
# resource_for :document, except: :delete
@@ -122,9 +115,36 @@
# # name: 'Pokemon',
# # publisher: {
# # name: 'Nintendo'
# # }
# }
+ #
+ # @example Controller with before_save
+ # class PokemonsController < ApplicationController
+ # include Azeroth::Resourceable
+ #
+ # resource_for :pokemon,
+ # only: %i[create update],
+ # before_save: :set_favorite
+ #
+ # private
+ #
+ # def set_favorite
+ # pokemon.favorite = true
+ # end
+ #
+ # def pokemons
+ # master.pokemons
+ # end
+ #
+ # def master
+ # @master ||= PokemonMaster.find(master_id)
+ # end
+ #
+ # def master_id
+ # params.require(:pokemon_master_id)
+ # end
+ # end
def resource_for(name, **options)
Builder.new(
self, name, Azeroth::Options.new(options)
).build
end