Method: AWSData::Base#initialize

Defined in:
lib/aws-data/base.rb

#initializeBase

Returns a new instance of Base.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/aws-data/base.rb', line 18

def initialize
  # Setup the finders, or throw an exception if their IP isn't routable
  unless self.class._base_path
    raise "Can't instanciate without a base_path"
  end

  methods = parse_endpoint_data(transport.get(self.class._base_path))

  methods.each do |m|
    method_name = m.name.gsub(/-/, "_").to_sym
    if m.finder
      eigenclass.send(:define_method, method_name) do
        Finder.new("#{self.class._base_path}/#{m.name}/")
      end
    else
      eigenclass.send(:define_method, method_name) do
        transport.get("#{self.class._base_path}/#{m.name}")
      end
    end
  end
end