Module: Nested::Sinatra
- Defined in:
- lib/nested.rb
Instance Method Summary collapse
- #create_resource(name, singleton, collection, init_block, &block) ⇒ Object
- #many(name, init_block = nil, &block) ⇒ Object
- #nested_config(config = nil) ⇒ Object
- #one(name, init_block = nil, &block) ⇒ Object
- #singleton(name, init_block = nil, &block) ⇒ Object
Instance Method Details
#create_resource(name, singleton, collection, init_block, &block) ⇒ Object
479 480 481 |
# File 'lib/nested.rb', line 479 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
473 474 475 |
# File 'lib/nested.rb', line 473 def many(name, init_block=nil, &block) create_resource(name, false, true, init_block, &block) end |
#nested_config(config = nil) ⇒ Object
463 464 465 466 467 468 469 |
# File 'lib/nested.rb', line 463 def nested_config(config=nil) if config @nested_config = config else @nested_config ||= {} end end |
#one(name, init_block = nil, &block) ⇒ Object
476 477 478 |
# File 'lib/nested.rb', line 476 def one(name, init_block=nil, &block) create_resource(name, false, false, init_block, &block) end |
#singleton(name, init_block = nil, &block) ⇒ Object
470 471 472 |
# File 'lib/nested.rb', line 470 def singleton(name, init_block=nil, &block) create_resource(name, true, false, init_block, &block) end |