Class: Expressir::Liquid::Declarations::SchemaDrop

Inherits:
Expressir::Liquid::DeclarationDrop show all
Includes:
IdentifierDrop
Defined in:
lib/expressir/liquid/declarations/schema_drop.rb

Instance Method Summary collapse

Methods included from IdentifierDrop

#id, #initialize_identifier, #remark_items, #source

Methods inherited from ModelElementDrop

#_class, #source

Constructor Details

#initialize(model, selected_schemas: nil, options: {}) ⇒ SchemaDrop

rubocop:disable Lint/MissingSuper



9
10
11
12
13
14
15
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 9

def initialize(model, selected_schemas: nil, options: {}) # rubocop:disable Lint/MissingSuper
  @model = model
  @selected_schemas = selected_schemas
  @options = options
  initialize_identifier(@model)
  super(model)
end

Instance Method Details

#constantsObject



69
70
71
72
73
74
75
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 69

def constants
  return [] unless @model.constants

  @model.constants.map do |item|
    ::Expressir::Liquid::Declarations::ConstantDrop.new(item)
  end
end

#entitiesObject



85
86
87
88
89
90
91
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 85

def entities
  return [] unless @model.entities

  @model.entities.map do |item|
    ::Expressir::Liquid::Declarations::EntityDrop.new(item)
  end
end

#fileObject



17
18
19
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 17

def file
  @model.file
end

#file_basenameObject



21
22
23
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 21

def file_basename
  File.basename(@model.file, ".exp")
end

#formattedObject



125
126
127
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 125

def formatted
  @model.to_s(no_remarks: true)
end

#functionsObject



101
102
103
104
105
106
107
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 101

def functions
  return [] unless @model.functions

  @model.functions.map do |item|
    ::Expressir::Liquid::Declarations::FunctionDrop.new(item)
  end
end

#interfacesObject



61
62
63
64
65
66
67
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 61

def interfaces
  return [] unless @model.interfaces

  @model.interfaces.map do |item|
    ::Expressir::Liquid::Declarations::InterfaceDrop.new(item)
  end
end

#proceduresObject



117
118
119
120
121
122
123
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 117

def procedures
  return [] unless @model.procedures

  @model.procedures.map do |item|
    ::Expressir::Liquid::Declarations::ProcedureDrop.new(item)
  end
end

#relative_path_prefixObject



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 30

def relative_path_prefix
  return nil if @options.nil? || @options["document"].nil?

  document = @options["document"]
  file_path = File.dirname(@model.file)
  docfile_directory = File.dirname(
    document.attributes["docfile"] || ".",
  )
  document
    .path_resolver
    .system_path(file_path, docfile_directory)
end

#remarksObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 43

def remarks
  return [] unless @model.remarks

  options = @options || {}
  options["relative_path_prefix"] = relative_path_prefix

  @model.remarks.map do |remark|
    ::Expressir::Express::ExpressRemarksDecorator
      .call(remark, options)
  end
end

#rulesObject



109
110
111
112
113
114
115
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 109

def rules
  return [] unless @model.rules

  @model.rules.map do |item|
    ::Expressir::Liquid::Declarations::RuleDrop.new(item)
  end
end

#selectedObject



25
26
27
28
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 25

def selected
  @selected_schemas&.include?(@model.id) ||
    @selected_schemas&.include?(file_basename)
end

#subtype_constraintsObject



93
94
95
96
97
98
99
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 93

def subtype_constraints
  return [] unless @model.subtype_constraints

  @model.subtype_constraints.map do |item|
    ::Expressir::Liquid::Declarations::SubtypeConstraintDrop.new(item)
  end
end

#typesObject



77
78
79
80
81
82
83
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 77

def types
  return [] unless @model.types

  @model.types.map do |item|
    ::Expressir::Liquid::Declarations::TypeDrop.new(item)
  end
end

#versionObject



55
56
57
58
59
# File 'lib/expressir/liquid/declarations/schema_drop.rb', line 55

def version
  ::Expressir::Liquid::Declarations::SchemaVersionDrop.new(
    @model.version,
  )
end