Class: Trust::Controller::Resource::ParentInfo
- Defined in:
- lib/trust/controller/resource.rb
Overview
Resource::ParentInfo
Resolves the parent resource in subject (see #Resource::ResourceInfo)
Instance Attribute Summary collapse
-
#as ⇒ Object
readonly
Returns the value of attribute as.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Attributes inherited from Info
Instance Method Summary collapse
-
#initialize(resources, params, request) ⇒ ParentInfo
constructor
A new instance of ParentInfo.
- #object? ⇒ Boolean
- #real_class ⇒ Object
Constructor Details
#initialize(resources, params, request) ⇒ ParentInfo
Returns a new instance of ParentInfo.
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 |
# File 'lib/trust/controller/resource.rb', line 319 def initialize(resources, params, request) ptr = resources.detect do |r,as| @klass = classify(r) @as = as ([@klass] + @klass.descendants).detect do |c| @name = c.to_s.underscore.tr('/','_').to_sym unless @id = request.symbolized_path_parameters["#{@name}_id".to_sym] # see if name space handling is necessary if c.to_s.include?('::') @name = c.to_s.demodulize.underscore.to_sym @id = request.symbolized_path_parameters["#{@name}_id".to_sym] end end @id end @id end if ptr @object = @klass.find(@id) else @klass = @name = nil end @data = params[var_name(ptr)] end |
Instance Attribute Details
#as ⇒ Object (readonly)
Returns the value of attribute as.
318 319 320 |
# File 'lib/trust/controller/resource.rb', line 318 def as @as end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
318 319 320 |
# File 'lib/trust/controller/resource.rb', line 318 def object @object end |
Instance Method Details
#object? ⇒ Boolean
344 345 346 |
# File 'lib/trust/controller/resource.rb', line 344 def object? !!@object end |
#real_class ⇒ Object
348 349 350 |
# File 'lib/trust/controller/resource.rb', line 348 def real_class @object && @object.class end |