Sha256: 920eb5142dc02c826d3ec1926fdabf212cf6779c8f0b978e76aed2af2941091b
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
module MakeRestful::ClassMethods def resource_name resource_class.name.gsub(/(.*::)?(.*)/,"\\2").underscore.pluralize end def instance_name resource_name.singularize end private def resource(klass) before_filter :verify_method! before_filter :load_resource before_filter :load_collection, only: [:index] before_filter :load_instance, only: [:show, :destroy, :update] self.resource_class = klass.to_s.classify.constantize end def find_by(key) self.finder = key.to_sym end def actions(*actions) options = actions.extract_options! self.allowed_actions.objects = actions if actions.present? self.allowed_actions.only(options[:only]) self.allowed_actions.except(options[:except]) end def formats(*formats) options = formats.extract_options! self.allowed_formats.objects = formats if formats.present? self.allowed_formats.only(options[:only]) self.allowed_formats.except(options[:except]) end def paginates!(opts={}) opts.reverse_merge!({ per_page: 25 }) self.pagination = opts end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
make_restful-0.1.4 | lib/make_restful/class_methods.rb |