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