Class: Domain::HeadingBased::DomainMethods
- Inherits:
-
Module
- Object
- Module
- Domain::HeadingBased::DomainMethods
- Defined in:
- lib/alf-core/ext/domain/heading_based.rb
Instance Method Summary collapse
-
#initialize(master_class, gt) ⇒ DomainMethods
constructor
A new instance of DomainMethods.
Constructor Details
#initialize(master_class, gt) ⇒ DomainMethods
Returns a new instance of DomainMethods.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/alf-core/ext/domain/heading_based.rb', line 25 def initialize(master_class, gt) define_method(:generating_type){ gt } define_method(:<=>){|other| return nil unless other.ancestors.include?(master_class) return -1 if other == master_class to_heading <=> other.to_heading } define_method(:===){|value| super(value) || (value.is_a?(master_class) && self >= value.class) } define_method(:hash){ @hash ||= 37*master_class.hash + .hash } define_method(:==){|other| other.is_a?(Class) && other.superclass==master_class && other.to_heading==to_heading } define_method(:coerce){|arg| master_class.coercions.apply(arg, self) } define_method(:to_heading){ @heading ||= Alf::Heading.coerce() } define_method(:to_ruby_literal){ "#{master_class.name}[#{Alf::Support.to_ruby_literal(to_heading.to_hash)}]" } alias_method :name, :to_ruby_literal alias_method :to_s, :to_ruby_literal alias_method :inspect, :to_ruby_literal end |