class Saru::Builder
Constants
- TYPES
Attributes
levels[R]
type[R]
Public Class Methods
new(type, levels = nil)
click to toggle source
# File lib/saru/builder.rb, line 12 def initialize type, levels = nil @type = type @levels = levels end
Public Instance Methods
call()
click to toggle source
# File lib/saru/builder.rb, line 17 def call raise ArgumentError, 'Not valid type' unless TYPES.include?(type) build end
Private Instance Methods
build()
click to toggle source
# File lib/saru/builder.rb, line 25 def build request_items = request['requested_information'] items = request_items.map{|item| build_class.new flatten(item) } List.new items end
build_class()
click to toggle source
# File lib/saru/builder.rb, line 36 def build_class Module.const_get "Saru::#{type.capitalize}" end
flatten(item)
click to toggle source
# File lib/saru/builder.rb, line 40 def flatten item item.merge!(item['user_specific']) if item['user_specific'] item.delete_if{|key, _value| key == 'user_specific' } end
request()
click to toggle source
# File lib/saru/builder.rb, line 32 def request Connection.send(type, levels) end