Class: Pancake::Stacks::Short

Inherits:
Pancake::Stack show all
Defined in:
lib/pancake/stacks/short/stack.rb,
lib/pancake/stacks/short/controller.rb

Defined Under Namespace

Classes: Controller

Instance Attribute Summary

Attributes inherited from Pancake::Stack

#app_name

Class Method Summary collapse

Methods inherited from Pancake::Stack

_router, add_root, configuration, #configuration, create_bootloader_hook, #initialize, initialize_stack, initialized?, load_rake_tasks!, reset_router!, router, stackup, symlink_public_files!, with_router

Methods included from Hooks::OnInherit

extended, #inherited, #on_inherit

Methods included from Middleware

build, extended, #middlewares, #stack, #use

Methods included from Paths

#dirs_and_glob_for, #dirs_for, extended, #paths_for, #push_paths, #unique_paths_for

Constructor Details

This class inherits a constructor from Pancake::Stack

Class Method Details

.as(*args) ⇒ Object

See Also:



22
23
24
# File 'lib/pancake/stacks/short/stack.rb', line 22

def self.as(*args)
  self::Controller.as(*args)
end

.delete(path, opts = {}, &block) ⇒ Object

Deletes the resource at a given path

The block should finish with the final result of the action

Examples:

delete "/posts/foo-is-post" do
  # do stuff to post foo-is-post and render the result
end

Parameters:

  • path (String)
    • a url path that conforms to Usher match path.

  • block
    • the contents of the block are executed when the path is matched.

See Also:

  • Usher

Author:

  • Daniel Neighman



107
108
109
# File 'lib/pancake/stacks/short/stack.rb', line 107

def self.delete(path, opts = {}, &block)
  define_published_action(:delete, path, opts, block)
end

.get(path, opts = {}, &block) ⇒ Object

Gets a resource at a given path

The block should finish with the final result of the action

Examples:

get "/posts(/:year(/:month(/:date))" do
  # do stuff to get posts and render them
end

Parameters:

  • path (String)
    • a url path that conforms to Usher match path.

  • block
    • the contents of the block are executed when the path is matched.

See Also:

  • Usher

Author:

  • Daniel Neighman



50
51
52
# File 'lib/pancake/stacks/short/stack.rb', line 50

def self.get(path, opts = {}, &block)
  define_published_action(:get, path, opts, block)
end

.handle_exception(*args, &block) ⇒ Object



31
32
33
# File 'lib/pancake/stacks/short/stack.rb', line 31

def self.handle_exception(*args, &block)
  self::Controller.handle_exception(*args, &block)
end

.new_app_instanceObject



6
7
8
# File 'lib/pancake/stacks/short/stack.rb', line 6

def self.new_app_instance
  self::Controller
end

.post(path, opts = {}, &block) ⇒ Object

Posts a resource to a given path

The block should finish with the final result of the action

Examples:

post "/posts" do
  # do stuff to post  /posts and render them
end

Parameters:

  • path (String)
    • a url path that conforms to Usher match path.

  • block
    • the contents of the block are executed when the path is matched.

See Also:

  • Usher

Author:

  • Daniel Neighman



69
70
71
# File 'lib/pancake/stacks/short/stack.rb', line 69

def self.post(path, opts = {}, &block)
  define_published_action(:post, path, opts,  block)
end

.provides(*formats) ⇒ Object



27
28
29
# File 'lib/pancake/stacks/short/stack.rb', line 27

def self.provides(*formats)
  self::Controller.provides(*formats)
end

.publish(*args) ⇒ Object

Marks a method as published. This is done implicitly when using the get, post, put, delete methods on a Stacks::Short But can be done explicitly



16
17
18
19
# File 'lib/pancake/stacks/short/stack.rb', line 16

def self.publish(*args)
  @published = true
  self::Controller.publish(*args)
end

.put(path, opts = {}, &block) ⇒ Object

Puts a resource to a given path

The block should finish with the final result of the action

Examples:

put "/posts" do
  # do stuff to post  /posts and render them
end

Parameters:

  • path (String)
    • a url path that conforms to Usher match path.

  • block
    • the contents of the block are executed when the path is matched.

See Also:

  • Usher

Author:

  • Daniel Neighman



88
89
90
# File 'lib/pancake/stacks/short/stack.rb', line 88

def self.put(path, opts = {}, &block)
  define_published_action(:put, path, opts, block)
end