Module: Waves::Foundations::REST::ConvenienceMethods

Defined in:
lib/waves/foundations/rest.rb

Overview

Discrete set of methods to include globally.

Instance Method Summary collapse

Instance Method Details

#application(name, &block) ⇒ Object

Application definition block.



273
274
275
276
277
278
279
280
281
282
283
284
# File 'lib/waves/foundations/rest.rb', line 273

def application(name, &block)
  app = Class.new Application, &block

  if app.resources.nil? or app.resources.empty?
    raise BadDefinition, "No resource composition!"
  end

  mod = if Module === self then self else Object end
  mod.const_set name, app

  Waves << app
end

#resource(name, &block) ⇒ Object

TODO:

Must change the Waves.main to current app. –rue

Resource definition block.



290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/waves/foundations/rest.rb', line 290

def resource(name, &block)
  mod = if Module === self then self else Object end

  res = mod.const_set name, Class.new(Resource)

  Waves.main.register res

  # We must eval this, because the constant really needs
  # to be defined at the point we are running the body
  # code. --rue
  res.instance_eval &block
end