Class: Colombo::Container

Inherits:
Array
  • Object
show all
Defined in:
lib/colombo/container.rb

Direct Known Subclasses

Droplets, Images, Regions, Sizes, SshKeys

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/colombo/container.rb', line 6

def method_missing(method, *args, &block)
  if method.to_s =~ /^find_by_(.*)/
    run_find_by_attr($1, *args)
  else
    super
  end
end

Instance Method Details

#find(id) ⇒ Object



18
19
20
# File 'lib/colombo/container.rb', line 18

def find(id)
  find_by_id(id)
end

#run_find_by_attr(method, *args) ⇒ Object



14
15
16
# File 'lib/colombo/container.rb', line 14

def run_find_by_attr(method, *args)
  self.select{ |item| item.send(method.to_sym) == args[0] }.first
end