Class: ShortStack

Inherits:
Pancake::Stack
  • Object
show all
Defined in:
lib/short_stack.rb,
lib/short_stack/controller.rb

Defined Under Namespace

Classes: Controller

Class Method Summary collapse

Class Method Details

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

Matches any method to the route



138
139
140
# File 'lib/short_stack.rb', line 138

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

.as(*args) ⇒ Object

See Also:

  • Pancake::Mixins::Publish#as


33
34
35
# File 'lib/short_stack.rb', line 33

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

.base_template_nameObject



55
56
57
# File 'lib/short_stack.rb', line 55

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



132
133
134
# File 'lib/short_stack.rb', line 132

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



75
76
77
# File 'lib/short_stack.rb', line 75

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

.handle_exception(*args, &block) ⇒ Object



42
43
44
# File 'lib/short_stack.rb', line 42

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

.helpers(&blk) ⇒ Object



46
47
48
49
# File 'lib/short_stack.rb', line 46

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

.new_endpoint_instanceObject



17
18
19
# File 'lib/short_stack.rb', line 17

def self.new_endpoint_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



94
95
96
# File 'lib/short_stack.rb', line 94

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

.provides(*formats) ⇒ Object

See Also:

  • Pancake::Mixins::Publish#provides


38
39
40
# File 'lib/short_stack.rb', line 38

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

See Also:

  • Pancake::Mixins::Publish#publish


27
28
29
30
# File 'lib/short_stack.rb', line 27

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



113
114
115
# File 'lib/short_stack.rb', line 113

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

.template(*args) ⇒ Object



51
52
53
# File 'lib/short_stack.rb', line 51

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