Class: Nested::App

Inherits:
Object
  • Object
show all
Extended by:
WithMany, WithSingleton
Defined in:
lib/nested/app.rb

Class Method Summary collapse

Methods included from WithSingleton

singleton, singleton_if

Methods included from WithMany

many, many_if

Class Method Details

.after(&block) ⇒ Object



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

def self.after(&block)
  sinatra.after(&block)
  self
end

.before(&block) ⇒ Object



22
23
24
25
# File 'lib/nested/app.rb', line 22

def self.before(&block)
  sinatra.before(&block)
  self
end

.behavior(name, &block) ⇒ Object



12
13
14
15
# File 'lib/nested/app.rb', line 12

def self.behavior(name, &block)
  @behaviors[name] = block
  self
end

.child_resource(name, clazz, resource_if_block, model_block, &block) ⇒ Object



17
18
19
20
# File 'lib/nested/app.rb', line 17

def self.child_resource(name, clazz, resource_if_block, model_block, &block)
   clazz.new(self, sinatra, name, nil, resource_if_block, model_block)
        .tap{|r| r.instance_eval(&(block||Proc.new{ }))}
end

.config(opts = {}) ⇒ Object



32
33
34
# File 'lib/nested/app.rb', line 32

def self.config(opts={})
  @config.tap{|c| c.merge!(opts)}
end

.inherited(clazz) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/nested/app.rb', line 3

def self.inherited(clazz)
  (class << clazz; self; end).instance_eval do
    attr_accessor :sinatra, :behaviors
  end
  clazz.sinatra = Class.new(Sinatra::Base)
  clazz.instance_variable_set("@config", {})
  clazz.instance_variable_set("@behaviors", {})
end