Sha256: 3685ed2be59b70d386d56148ae9fc83acfd5c2377ea85599689c95ade58958f1

Contents?: true

Size: 537 Bytes

Versions: 18

Compression:

Stored size: 537 Bytes

Contents

class ExplicitDelegator < SimpleDelegator

  def initialize(obj)
    super(obj)
    ensure_defined
  end

  def enforced_methods
    []
  end

  def ensure_defined
    missing_methods = []
    enforced_methods.each do |method|
      missing_methods << method unless __getobj__.methods.include?(method)
    end
    raise "Methods required to use #{self.class}: #{missing_methods}" unless missing_methods.empty?
  end

  def self.enforce_definitions(*methods)
    define_method(:enforced_methods) do
      return methods
    end
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
woople-theme-0.5.5 lib/explicit_delegator.rb
woople-theme-0.5.4 lib/explicit_delegator.rb
woople-theme-0.5.3 lib/explicit_delegator.rb
woople-theme-0.5.2 lib/explicit_delegator.rb
woople-theme-0.5.0.1 lib/explicit_delegator.rb
woople-theme-0.5.0 lib/explicit_delegator.rb
woople-theme-0.4.2 lib/explicit_delegator.rb
woople-theme-0.4.1 lib/explicit_delegator.rb
woople-theme-0.4.0 lib/explicit_delegator.rb
woople-theme-0.3.9 lib/explicit_delegator.rb
woople-theme-0.3.8 lib/explicit_delegator.rb
woople-theme-0.3.7 lib/explicit_delegator.rb
woople-theme-0.3.6 lib/explicit_delegator.rb
woople-theme-0.3.5 lib/explicit_delegator.rb
woople-theme-0.3.04 lib/explicit_delegator.rb
woople-theme-0.3.03 lib/explicit_delegator.rb
woople-theme-0.3.02 lib/explicit_delegator.rb
woople-theme-0.3.01 lib/explicit_delegator.rb