Module: Jellyfish::DSL

Defined in:
lib/jellyfish.rb

Overview


Instance Method Summary collapse

Instance Method Details

#controller(value = GetValue) ⇒ Object



147
148
149
150
151
152
153
154
# File 'lib/jellyfish.rb', line 147

def controller value=GetValue
  if value == GetValue
    @controller ||= controller_inject(
      const_set(:Controller, Class.new(Controller)))
  else
    @controller   = controller_inject(value)
  end
end

#controller_include(*value) ⇒ Object



143
144
145
# File 'lib/jellyfish.rb', line 143

def controller_include *value
  (@controller_include ||= []).push(*value)
end

#controller_inject(value) ⇒ Object



156
157
158
159
# File 'lib/jellyfish.rb', line 156

def controller_inject value
  controller_include.
    inject(value){ |ctrl, mod| ctrl.__send__(:include, mod) }
end

#handle(*exceptions, &block) ⇒ Object



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

def handle *exceptions, &block
  exceptions.each{ |exp| handlers[exp] = block }
end

#handle_exceptions(value = GetValue) ⇒ Object



135
136
137
138
139
140
141
# File 'lib/jellyfish.rb', line 135

def handle_exceptions value=GetValue
  if value == GetValue
    @handle_exceptions
  else
    @handle_exceptions = value
  end
end

#handlersObject



131
# File 'lib/jellyfish.rb', line 131

def handlers; @handlers ||= {}; end

#inherited(sub) ⇒ Object



171
172
173
174
175
176
177
178
# File 'lib/jellyfish.rb', line 171

def inherited sub
  sub.handle_exceptions(handle_exceptions)
  sub.controller_include(*controller_include)
  [:handlers, :routes].each{ |m|
    val = __send__(m).inject({}){ |r, (k, v)| r[k] = v.dup; r }
    sub.__send__(m).replace(val) # dup the routing arrays
  }
end

#routesObject



130
# File 'lib/jellyfish.rb', line 130

def routes  ; @routes   ||= {}; end