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, set_as_master!, 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

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

Matches any method to the route



128
129
130
# File 'lib/pancake/stacks/short/stack.rb', line 128

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

.as(*args) ⇒ Object

See Also:



24
25
26
# File 'lib/pancake/stacks/short/stack.rb', line 24

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

.base_template_nameObject



46
47
48
# File 'lib/pancake/stacks/short/stack.rb', line 46

def self.base_template_name
  self::Controller.base_template_name
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



122
123
124
# File 'lib/pancake/stacks/short/stack.rb', line 122

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



65
66
67
# File 'lib/pancake/stacks/short/stack.rb', line 65

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

.handle_exception(*args, &block) ⇒ Object



33
34
35
# File 'lib/pancake/stacks/short/stack.rb', line 33

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

.helpers(&blk) ⇒ Object



37
38
39
40
# File 'lib/pancake/stacks/short/stack.rb', line 37

def self.helpers(&blk)
  m = Module.new(&blk)
  self::Controller.class_eval{ include m }
end

.new_app_instanceObject



8
9
10
# File 'lib/pancake/stacks/short/stack.rb', line 8

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



84
85
86
# File 'lib/pancake/stacks/short/stack.rb', line 84

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

.provides(*formats) ⇒ Object



29
30
31
# File 'lib/pancake/stacks/short/stack.rb', line 29

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



18
19
20
21
# File 'lib/pancake/stacks/short/stack.rb', line 18

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



103
104
105
# File 'lib/pancake/stacks/short/stack.rb', line 103

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

.template(*args) ⇒ Object



42
43
44
# File 'lib/pancake/stacks/short/stack.rb', line 42

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