Module: Sinatra::Namespace::InstanceMethods

Defined in:
lib/sinatra/namespace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_namespaceObject

Returns the value of attribute current_namespace.



150
151
152
# File 'lib/sinatra/namespace.rb', line 150

def current_namespace
  @current_namespace
end

Instance Method Details

#after_filter!(base = self.class) ⇒ Object



160
161
162
163
164
165
# File 'lib/sinatra/namespace.rb', line 160

def after_filter!(base = self.class)
  super
  if base == self.class and singleton_class.after_filters
    singleton_class.after_filters.each { |b| instance_eval(&b) }
  end
end

#error_block!(*keys) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/sinatra/namespace.rb', line 168

def error_block!(*keys)
  keys.detect do |key|
    base = current_namespace || self.class
    while base.respond_to? :errors
      if block = base.errors[key]
        # found a handler, eval and return result
        return instance_eval(&block)
      else
        base = base.respond_to?(:base) ? base.base : base.superclass
      end
    end
  end
end

#filter!(type, base = self.class) ⇒ Object



153
154
155
156
157
158
# File 'lib/sinatra/namespace.rb', line 153

def filter!(type, base = self.class)
  super
  if type == :after and base == self.class and singleton_class.filters and singleton_class.after_filters
    singleton_class.after_filters.each { |b| instance_eval(&b) }
  end
end