Module: Moon::Abstract

Included in:
Module
Defined in:
lib/moon/packages/std/mixins/abstract/abstract.rb

Instance Method Summary collapse

Instance Method Details

#abstract(method_name) ⇒ Object

Creates a new abstract method. A abstract method will fail with a AbstractMethodError when called. It is intended to be rewritten in the subclass before usage.

Parameters:


10
11
12
13
14
# File 'lib/moon/packages/std/mixins/abstract/abstract.rb', line 10

def abstract(method_name)
  define_method method_name do |*|
    fail AbstractMethodError.new(method_name)
  end
end

#abstract_attr_accessor(method_name) ⇒ Object

Creates a abstract method, similar to attr_accessor

Parameters:


33
34
35
36
37
# File 'lib/moon/packages/std/mixins/abstract/abstract.rb', line 33

def abstract_attr_accessor(method_name)
  abstract_attr_writer(method_name)
  abstract_attr_reader(method_name)
  method_name
end

#abstract_attr_reader(method_name) ⇒ Object

Creates a abstract method, similar to attr_reader

Parameters:


26
27
28
# File 'lib/moon/packages/std/mixins/abstract/abstract.rb', line 26

def abstract_attr_reader(method_name)
  abstract method_name
end

#abstract_attr_writer(method_name) ⇒ Object

Creates a abstract method, similar to attr_writer

Parameters:


19
20
21
# File 'lib/moon/packages/std/mixins/abstract/abstract.rb', line 19

def abstract_attr_writer(method_name)
  abstract "#{method_name}="
end