Skip to content

Instantly share code, notes, and snippets.

@cableray
Created November 29, 2012 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cableray/4171712 to your computer and use it in GitHub Desktop.
Save cableray/4171712 to your computer and use it in GitHub Desktop.
module CheetahCub
class Transaction
attr_reader :transaction_delegate
delegate :save, to: :transaction_delegate
# def save
# transaction_delegate.save
# end
def initialize
@transaction_delegate = Config.module_prefix::Transaction.new
end
end
end
require 'cheetah_cub'
CheetahCub::Config.version= "1.1.1"
CheetahCub::Transaction.new.save # => Hello from 1.1.1
CheetahCub::Config.version= "1.1.2"
CheetahCub::Transaction.new.save # => Hello from 1.1.2
module CheetahCub
module Config
extend self
attr_accessor :version
def url
ENV["CHEETAH_CUB_API_URL"]
end
def module_prefix
class_eval("CheetahCub::X_#{version.gsub('.','_')}")
end
def version= version
@version = version
end
def version
@version || '1.1.1'
end
end
end
module CheetahCub
module X_1_1_1
class Transaction
def save
puts "Hello from 1.1.1"
end
end
end
end
module CheetahCub
module X_1_1_2
class Transaction
def save
puts "Hello from 1.1.2"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment