Class: ArchSpec::ConstantNode

Inherits:
Object
  • Object
show all
Defined in:
lib/archspec/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, kind:, path:, location:) ⇒ ConstantNode

Returns a new instance of ConstantNode.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/archspec/model.rb', line 32

def initialize(name:, kind:, path:, location:)
  @name = name
  @kind = kind
  @path = path
  @location = location
  @instance_methods = Set.new
  @class_methods = Set.new
  @method_definitions = []
  @mixins = {
    include: Set.new,
    prepend: Set.new,
    extend: Set.new
  }
end

Instance Attribute Details

#class_methodsObject (readonly)

Returns the value of attribute class_methods.



29
30
31
# File 'lib/archspec/model.rb', line 29

def class_methods
  @class_methods
end

#instance_methodsObject (readonly)

Returns the value of attribute instance_methods.



29
30
31
# File 'lib/archspec/model.rb', line 29

def instance_methods
  @instance_methods
end

#kindObject (readonly)

Returns the value of attribute kind.



29
30
31
# File 'lib/archspec/model.rb', line 29

def kind
  @kind
end

#locationObject (readonly)

Returns the value of attribute location.



29
30
31
# File 'lib/archspec/model.rb', line 29

def location
  @location
end

#method_definitionsObject (readonly)

Returns the value of attribute method_definitions.



29
30
31
# File 'lib/archspec/model.rb', line 29

def method_definitions
  @method_definitions
end

#mixinsObject (readonly)

Returns the value of attribute mixins.



29
30
31
# File 'lib/archspec/model.rb', line 29

def mixins
  @mixins
end

#nameObject (readonly)

Returns the value of attribute name.



29
30
31
# File 'lib/archspec/model.rb', line 29

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



29
30
31
# File 'lib/archspec/model.rb', line 29

def path
  @path
end

#superclassObject

Returns the value of attribute superclass.



30
31
32
# File 'lib/archspec/model.rb', line 30

def superclass
  @superclass
end

Instance Method Details

#add_class_method(name, location:) ⇒ Object



60
61
62
63
# File 'lib/archspec/model.rb', line 60

def add_class_method(name, location:)
  class_methods.add(name.to_sym)
  method_definitions << MethodDefinition.new(self.name, name.to_sym, :class, location)
end

#add_instance_method(name, location:) ⇒ Object



55
56
57
58
# File 'lib/archspec/model.rb', line 55

def add_instance_method(name, location:)
  instance_methods.add(name.to_sym)
  method_definitions << MethodDefinition.new(self.name, name.to_sym, :instance, location)
end

#add_mixin(kind, name) ⇒ Object



65
66
67
# File 'lib/archspec/model.rb', line 65

def add_mixin(kind, name)
  mixins.fetch(kind).add(name)
end

#class?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/archspec/model.rb', line 47

def class?
  kind == :class
end

#module?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/archspec/model.rb', line 51

def module?
  kind == :module
end