File: abstract_method.rb

package info (click to toggle)
ruby-librarian 1.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 624 kB
  • sloc: ruby: 6,109; makefile: 11
file content (21 lines) | stat: -rw-r--r-- 456 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Librarian
  module Support
    module AbstractMethod

      class << self
        def included(base)
          base.extend ClassMethods
        end
      end

      module ClassMethods
        def abstract_method(*names)
          names.reject{|name| respond_to?(name)}.each do |name, *args|
            define_method(name) { raise Exception, "Method #{self.class.name}##{name} is abstract!" }
          end
        end
      end

    end
  end
end