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
424 425 426 |
# File 'lib/nested.rb', line 424 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
418 419 420 |
# File 'lib/nested.rb', line 418 def many(name, &block) create_resource(name, false, true, &block) end |
#nested_config(config = nil) ⇒ Object
408 409 410 411 412 413 414 |
# File 'lib/nested.rb', line 408 def nested_config(config=nil) if config @nested_config = config else @nested_config ||= {} end end |
#one(name, &block) ⇒ Object
421 422 423 |
# File 'lib/nested.rb', line 421 def one(name, &block) create_resource(name, false, false, &block) end |
#singleton(name, &block) ⇒ Object
415 416 417 |
# File 'lib/nested.rb', line 415 def singleton(name, &block) create_resource(name, true, false, &block) end |