Module: Ice::Cubeable

Defined in:
lib/ice/cubeable.rb

Instance Method Summary collapse

Instance Method Details

#get_cube_class(class_obj) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/ice/cubeable.rb', line 3

def get_cube_class(class_obj)
  begin
    cube_string = class_obj.to_s + "Cube"
    cube_string.constantize
  rescue
    get_cube_class class_obj.superclass
  end
end

#to_iceObject



12
13
14
15
16
17
18
19
# File 'lib/ice/cubeable.rb', line 12

def to_ice
  begin
    cube_class = get_cube_class self.class
    cube_class.new self
  rescue
    raise "Cannot find Cube class for model that you are calling to_ice on."
  end
end