class EnumArgs::Proxy
Constants
- CREATE_ENUM
Attributes
args[RW]
cache[RW]
enum[W]
method_name[RW]
object[RW]
using[R]
Public Class Methods
new(object, method_name, *args, using: {}, cache: nil)
click to toggle source
# File lib/enum_args/proxy.rb, line 15 def initialize(object, method_name, *args, using: {}, cache: nil) self.using = using @object = object @method_name = method_name @args = args @cache = cache || CREATE_ENUM end
Public Instance Methods
using=(using)
click to toggle source
# File lib/enum_args/proxy.rb, line 23 def using=(using) raise TypeError, "expected Hash, found #{using.class}" unless using.is_a? Hash @using = using end
Private Instance Methods
build_enum(merge = {})
click to toggle source
# File lib/enum_args/proxy.rb, line 48 def build_enum(merge = {}) cache.call(object, method_name, args, using.merge(merge), CREATE_ENUM) end
enum_delegate(m, m_args, options, blk)
click to toggle source
# File lib/enum_args/proxy.rb, line 32 def enum_delegate(m, m_args, options, blk) # remove specific 'using' options from method call iterator_params = extract_iterator_params_from options m_args << options unless options.empty? build_enum(iterator_params).send m, *m_args, &blk end
extract_iterator_params_from(options)
click to toggle source
# File lib/enum_args/proxy.rb, line 40 def extract_iterator_params_from(options) using.inject({}) do |acc, (k, _)| val = options.delete k acc[k] = val if val acc end end