def protect_resource_as(klass, args = {})
      if klass.is_a?(Hash)
        klass, args = self.class.resource_class, klass
      end
      @operated_resource = MetaResource.new(klass, args)
    end
def protect_resource_as(klass, args = {})
      if klass.is_a?(Hash)
        klass, args = self.class.resource_class, klass
      end
      @operated_resource = MetaResource.new(klass, args)
    end
Private: Call this method if you need to *change* the target
 resource to provision access and permission.

   def require_resources
     @resources = Post.where(user_id: @user.id)
   end

 By default, in `index` and `create` actions, Garage will check
 `:read` and `:write` access respectively on the default
 `resource_class` of `@resources`, in this case Post class.  If
 you need more fine grained control than that, you should specify
 the optional parameters here, such as:

   def require_resources
     @resources = Post.where(user_id: @user.id)
     protect_source_as PrivatePost, user: @user
   end

 This way, the token should require access scope to `PrivatePost`
 (instead of `Post`), and the authorized user should have a
 permission to operate the action on resources owned by `@user`
 (instead of public). The `:user` option will be passed as
 parameters to `build_permissions` class method.