Skip to content

Instantly share code, notes, and snippets.

@pmashchak
Last active December 30, 2015 03:41
Show Gist options
  • Save pmashchak/8d2a366c1687b482211b to your computer and use it in GitHub Desktop.
Save pmashchak/8d2a366c1687b482211b to your computer and use it in GitHub Desktop.
class A
attr_accessor :options
cattr_accessor :name
def initialize
self.options = { code: 200, controller: OpenStruct.new(log_state: true) }
self.class.name = :api_name
end
end
class B
attr_accessor :api_context, :options
def initialize
self.options = {}
self.api_context = A.new
end
extend Forwardable
def_delegator :api_context, :options, :api_options
def_delegator :api_options, :[], :get
def_delegator :api_context, :name, :api_name
def_delegator :'api_options[:controller]', :log_state
def get_code
get(:code)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment