Class: Orange::Radius

Inherits:
Resource
  • Object
show all
Defined in:
lib/orange-more/slices/resources/radius.rb

Overview

Radius resource is for exposing the Radius context and allowing parsing.

Instance Method Summary collapse

Instance Method Details

#afterLoadObject



8
9
10
11
12
# File 'lib/orange-more/slices/resources/radius.rb', line 8

def afterLoad
  @context = ::Radius::PacketContext.new
  @defined_tags = []
  orange.fire(:radius_loaded, self)
end

#contextObject



14
15
16
# File 'lib/orange-more/slices/resources/radius.rb', line 14

def context
  @context
end

#define_tag(*args, &block) ⇒ Object



22
23
24
25
# File 'lib/orange-more/slices/resources/radius.rb', line 22

def define_tag(*args, &block)
  @defined_tags << args.first unless @defined_tags.include? args.first
  @context.define_tag(*args, &block)
end

#defined_tagsObject



18
19
20
# File 'lib/orange-more/slices/resources/radius.rb', line 18

def defined_tags
  @defined_tags
end

#parse(packet) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/orange-more/slices/resources/radius.rb', line 35

def parse(packet)
  content = packet[:content, false]
  unless content.blank? 
    parser = ::Radius::PacketParser.new(context, :tag_prefix => 'o')
    packet[:content] = parser.parse(content, packet)
  end
end

#parse_text(packet, text = false) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/orange-more/slices/resources/radius.rb', line 27

def parse_text(packet, text = false)
  content = text
  unless content.blank? 
    parser = ::Radius::PacketParser.new(context, :tag_prefix => 'o')
    parser.parse(content, packet)
  end
end