Class: WEEL::ReadStructure

Inherits:
Object
  • Object
show all
Defined in:
lib/weel.rb

Overview

}}}

Instance Method Summary collapse

Constructor Details

#initialize(data, endpoints, additional) ⇒ ReadStructure

{{{



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/weel.rb', line 44

def initialize(data,endpoints,additional)
  @__weel_data = data.dup
  @__weel_data.transform_values! do |v|
    if Object.const_defined?(:XML) && XML.const_defined?(:Smart) && v.is_a?(XML::Smart::Dom)
      v.root.to_doc
    else
      begin
        Marshal.load(Marshal.dump(v))
      rescue
        v.to_s rescue nil
      end
    end
  end
  @__weel_endpoints = endpoints.dup
  @__weel_endpoints.transform_values!{ |v| v.dup }
  @additional = additional
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, args, &block) ⇒ Object



62
63
64
65
66
67
68
69
70
# File 'lib/weel.rb', line 62

def method_missing(m,args,&block)
  if @additional.exists?(m)
    begin
      Marshal.load(Marshal.dump(@aditional[m]))
    rescue
      v.to_s rescue nil
    end
  end
end

Instance Method Details

#dataObject



71
72
73
# File 'lib/weel.rb', line 71

def data
  ReadHash.new(@__weel_data)
end

#endpointsObject



74
75
76
# File 'lib/weel.rb', line 74

def endpoints
  ReadHash.new(@__weel_endpoints)
end