class Immutabler::DSL::Group

Attributes

enums[RW]
models[RW]
name[RW]
output_directory[RW]
prefix[RW]

Public Class Methods

new(name) click to toggle source
# File lib/immutabler/dsl/group.rb, line 12
def initialize(name)
  @prefix = ''
  @base_model = 'NSObject'
  @name = name
  @models = []
  @enums = []
  @links = []
  @module_links = []
end

Public Instance Methods

base_model(name) click to toggle source
# File lib/immutabler/dsl/group.rb, line 38
def base_model(name)
  @base_model = name
end
build() click to toggle source
# File lib/immutabler/dsl/group.rb, line 62
def build
  {
    name: name,
    models: models,
    links: links,
    module_links: module_links,
    enums: enums,
  }
end
enum(name, &block) click to toggle source
# File lib/immutabler/dsl/group.rb, line 42
def enum(name, &block)
  attributes = []
  prefix = "#{@prefix}#{name}"
  EnumAttributesBuilder.new(attributes, prefix, &block)
  @enums << Enum.new(prefix, attributes)
end
model(name, options = {}, &block) click to toggle source
# File lib/immutabler/dsl/group.rb, line 49
def model(name, options = {}, &block)
  prefix = @prefix + name.to_s
  base = options.fetch(:base, @base_model).to_s
  base_immutable = options.fetch(:base_immutable, false)
  builder_base = options.fetch(:builder_base, base).to_s
  props = []
  ModelAttributesBuilder.new(props, &block)

  model = Model.new(prefix, base, base_immutable, builder_base, props)

  models << model
end
output_dir(dir) click to toggle source
# File lib/immutabler/dsl/group.rb, line 34
def output_dir(dir)
  self.output_directory = dir
end