Module: Nested::Sinatra

Defined in:
lib/nested.rb

Instance Method Summary collapse

Instance Method Details

#create_resource(name, singleton, collection, init_block, &block) ⇒ Object



507
508
509
# File 'lib/nested.rb', line 507

def create_resource(name, singleton, collection, init_block, &block)
  ::Nested::Resource.new(self, name, singleton, collection, nil, init_block).tap{|r| r.instance_eval(&block) }
end

#many(name, init_block = nil, &block) ⇒ Object



501
502
503
# File 'lib/nested.rb', line 501

def many(name, init_block=nil, &block)
  create_resource(name, false, true, init_block, &block)
end

#nested_config(config = nil) ⇒ Object



491
492
493
494
495
496
497
# File 'lib/nested.rb', line 491

def nested_config(config=nil)
  if config
    @nested_config = config
  else
    @nested_config ||= {}
  end
end

#one(name, init_block = nil, &block) ⇒ Object



504
505
506
# File 'lib/nested.rb', line 504

def one(name, init_block=nil, &block)
  create_resource(name, false, false, init_block, &block)
end

#singleton(name, init_block = nil, &block) ⇒ Object



498
499
500
# File 'lib/nested.rb', line 498

def singleton(name, init_block=nil, &block)
  create_resource(name, true, false, init_block, &block)
end