Class: Domain::HeadingBased::AlgebraMethods

Inherits:
Module
  • Object
show all
Defined in:
lib/alf/ext/domain/heading_based.rb

Overview

module DomainMethods

Instance Method Summary collapse

Constructor Details

#initialize(master_class, generating_type) ⇒ AlgebraMethods

Returns a new instance of AlgebraMethods


85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/alf/ext/domain/heading_based.rb', line 85

def initialize(master_class, generating_type)
  define_method(:heading){
    @heading ||= Alf::Heading.coerce(generating_type)
  }
  define_method(:split){|attr_list|
    if attr_list.empty?
      [ master_class::DUM.class, self ]
    elsif attr_list==heading.to_attr_list
      [ self, master_class::DUM.class ]
    else
      heading.split(attr_list).map{|h| master_class[h]}
    end
  }
  define_method(:project){|attr_list|
    split(attr_list).first
  }
  define_method(:allbut){|attr_list|
    split(attr_list).last
  }
  define_method(:rename){|renaming|
    master_class[heading.rename(renaming)]
  }
end