Module: Nested::Sinatra
- Defined in:
- lib/nested.rb
Instance Method Summary collapse
- #create_resource(name, singleton, collection, &block) ⇒ Object
- #many(name, &block) ⇒ Object
- #nested_config(config = nil) ⇒ Object
- #one(name, &block) ⇒ Object
- #singleton(name, &block) ⇒ Object
Instance Method Details
#create_resource(name, singleton, collection, &block) ⇒ Object
417 418 419 |
# File 'lib/nested.rb', line 417 def create_resource(name, singleton, collection, &block) ::Nested::Resource.new(self, name, singleton, collection, nil).tap{|r| r.instance_eval(&block) } end |
#many(name, &block) ⇒ Object
411 412 413 |
# File 'lib/nested.rb', line 411 def many(name, &block) create_resource(name, false, true, &block) end |
#nested_config(config = nil) ⇒ Object
401 402 403 404 405 406 407 |
# File 'lib/nested.rb', line 401 def nested_config(config=nil) if config @nested_config = config else @nested_config ||= {} end end |
#one(name, &block) ⇒ Object
414 415 416 |
# File 'lib/nested.rb', line 414 def one(name, &block) create_resource(name, false, false, &block) end |
#singleton(name, &block) ⇒ Object
408 409 410 |
# File 'lib/nested.rb', line 408 def singleton(name, &block) create_resource(name, true, false, &block) end |