class Unimatrix::Authorization::Parser
Public Class Methods
new( content = {}, request_path = "" ) { |self| ... }
click to toggle source
# File lib/unimatrix/authorization/parser.rb, line 5 def initialize( content = {}, request_path = "" ) @content = content @request_path = request_path yield self if block_given? end
Public Instance Methods
name()
click to toggle source
# File lib/unimatrix/authorization/parser.rb, line 11 def name @request_path[ 1...@request_path.length ] end
parse_resource( name, attributes )
click to toggle source
# File lib/unimatrix/authorization/parser.rb, line 38 def parse_resource( name, attributes ) resource = nil if attributes.present? class_name = name.singularize.camelize object_class = Unimatrix::Authorization.const_get( class_name ) rescue nil if object_class.present? resource = object_class.new( attributes ) end end resource end
resources()
click to toggle source
# File lib/unimatrix/authorization/parser.rb, line 19 def resources result = nil unless self.name.blank? if @content[ 'error' ] result = parse_resource( 'error', @content ) else unless @content[ name ].is_a?( Array ) result = [ parse_resource( name, @content ) ] else result = @content[ name ].map do | attributes | parse_resource( name, attributes ) end end end end result end
type_name()
click to toggle source
# File lib/unimatrix/authorization/parser.rb, line 15 def type_name self.name.present? ? name.singularize : nil end