Sha256: 2f214c2e15e614c042e20f8a3a1fa72a126e71a35cc7e9bdc717b6e7a08ed26c
Contents?: true
Size: 715 Bytes
Versions: 3
Compression:
Stored size: 715 Bytes
Contents
module Usable class ModExtender attr_reader :name attr_accessor :copy, :mod, :config def initialize(mod, config = OpenStruct.new) @mod = mod if has_spec? @copy = mod.const_get(:UsableSpec).dup @name = "#{mod.name}UsableSpec" else @copy = mod.dup @name = mod.name end @config = config end # @note Destructive def call override copy end def override unwanted = config.only ? copy.instance_methods - Array(config.only) : [] unwanted.each do |method_name| copy.send :remove_method, method_name end end def has_spec? mod.const_defined?(:UsableSpec) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
usable-1.2.1 | lib/usable/mod_extender.rb |
usable-1.2.0 | lib/usable/mod_extender.rb |
usable-1.1.1 | lib/usable/mod_extender.rb |