Class: Sinatra::Trails::Resource
Direct Known Subclasses
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Attributes inherited from Scope
#ancestors, #name, #path, #routes
Instance Method Summary collapse
- #generate_routes!(&block) ⇒ Object
-
#initialize(app, name, ancestors, opts) ⇒ Resource
constructor
A new instance of Resource.
- #member(action) ⇒ Object
Methods inherited from Scope
#after, #before, #map, #namespace, #resource, #resources, #route_for, #routes_hash
Constructor Details
#initialize(app, name, ancestors, opts) ⇒ Resource
Returns a new instance of Resource.
169 170 171 172 |
# File 'lib/sinatra/trails.rb', line 169 def initialize app, name, ancestors, opts super app, name.to_sym, ancestors @opts = opts end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Sinatra::Trails::Scope
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
168 169 170 |
# File 'lib/sinatra/trails.rb', line 168 def opts @opts end |
Instance Method Details
#generate_routes!(&block) ⇒ Object
183 184 185 |
# File 'lib/sinatra/trails.rb', line 183 def generate_routes! &block define_routes and super end |
#member(action) ⇒ Object
174 175 176 177 178 179 180 181 |
# File 'lib/sinatra/trails.rb', line 174 def member action ancestors = [*self.ancestors, name] path = @plural_name ? [plural_name, ':id'] : [name] ancestors.unshift(action) and path.push(action) unless action == :show ancestors.reject!{ |ancestor| Resource === ancestor } if opts[:shallow] Route.new(path, action.to_s, ancestors, self) end |