Sha256: 042f66521b156e859bc2324b935ee03f07df990d8bc338a503a99674fcc77cb0

Contents?: true

Size: 623 Bytes

Versions: 2

Compression:

Stored size: 623 Bytes

Contents

class Wallaby::Mode
  INTERFACE_METHODS = %w( model_decorator model_finder model_operator )

  INTERFACE_METHODS.each do |method_id|
    define_singleton_method method_id do
      begin
        method_class  = __callee__.to_s.classify
        class_name    = "#{ name }::#{ method_class }"
        parent_class  = "Wallaby::#{ method_class }".constantize
        class_name.constantize.tap do |klass|
          fail Wallaby::InvalidError, "#{ klass } must inherit #{ parent_class }" unless klass < parent_class
        end
      rescue NameError
        fail Wallaby::NotImplemented, class_name
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wallaby-4.1.6 lib/interfaces/wallaby/mode.rb
wallaby-5.0.1 lib/interfaces/wallaby/mode.rb