Module: Fried::Schema::Struct

Defined in:
lib/fried/schema/struct.rb

Overview

Provides attribute macro which allows to easily define type-safe accessors. The attributes are initialized with default values or with nil if none was provided

Defined Under Namespace

Modules: ClassMethods, Initializer

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/fried/schema/struct.rb', line 44

def self.included(klass)
  CreateDefinitionIfMissing.(klass)

  klass.instance_eval do
    include Initializer
    extend ClassMethods
    include ::Fried::Typings
    include Comparable
  end
end

Instance Method Details

#<=>(other) ⇒ Object



55
56
57
58
59
# File 'lib/fried/schema/struct.rb', line 55

def <=>(other)
  schema = GetDefinition.(self.class)

  Compare.(schema, self, other)
end