Class: Immutabler::DSL::Group
- Inherits:
-
Object
- Object
- Immutabler::DSL::Group
- Defined in:
- lib/immutabler/dsl/group.rb
Instance Attribute Summary collapse
-
#enums ⇒ Object
Returns the value of attribute enums.
-
#links ⇒ Object
Returns the value of attribute links.
-
#models ⇒ Object
Returns the value of attribute models.
-
#module_links ⇒ Object
Returns the value of attribute module_links.
-
#name ⇒ Object
Returns the value of attribute name.
-
#output_directory ⇒ Object
Returns the value of attribute output_directory.
-
#prefix(prefix) ⇒ Object
Returns the value of attribute prefix.
Instance Method Summary collapse
- #base_model(name) ⇒ Object
- #build ⇒ Object
- #enum(name, &block) ⇒ Object
-
#initialize(name) ⇒ Group
constructor
A new instance of Group.
- #link_to(model_group_name) ⇒ Object
- #model(name, options = {}, &block) ⇒ Object
- #module_link_to(module_name, file_name) ⇒ Object
- #output_dir(dir) ⇒ Object
Constructor Details
#initialize(name) ⇒ Group
Returns a new instance of Group.
12 13 14 15 16 17 18 19 20 |
# File 'lib/immutabler/dsl/group.rb', line 12 def initialize(name) @prefix = '' @base_model = 'NSObject' @name = name @models = [] @enums = [] @links = [] @module_links = [] end |
Instance Attribute Details
#enums ⇒ Object
Returns the value of attribute enums.
10 11 12 |
# File 'lib/immutabler/dsl/group.rb', line 10 def enums @enums end |
#links ⇒ Object
Returns the value of attribute links.
10 11 12 |
# File 'lib/immutabler/dsl/group.rb', line 10 def links @links end |
#models ⇒ Object
Returns the value of attribute models.
10 11 12 |
# File 'lib/immutabler/dsl/group.rb', line 10 def models @models end |
#module_links ⇒ Object
Returns the value of attribute module_links.
10 11 12 |
# File 'lib/immutabler/dsl/group.rb', line 10 def module_links @module_links end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/immutabler/dsl/group.rb', line 10 def name @name end |
#output_directory ⇒ Object
Returns the value of attribute output_directory.
10 11 12 |
# File 'lib/immutabler/dsl/group.rb', line 10 def output_directory @output_directory end |
#prefix(prefix) ⇒ Object
Returns the value of attribute prefix.
10 11 12 |
# File 'lib/immutabler/dsl/group.rb', line 10 def prefix @prefix end |
Instance Method Details
#base_model(name) ⇒ Object
38 39 40 |
# File 'lib/immutabler/dsl/group.rb', line 38 def base_model(name) @base_model = name end |
#build ⇒ Object
62 63 64 65 66 67 68 69 70 |
# 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) ⇒ Object
42 43 44 45 46 47 |
# 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 |
#link_to(model_group_name) ⇒ Object
26 27 28 |
# File 'lib/immutabler/dsl/group.rb', line 26 def link_to(model_group_name) links << model_group_name end |
#model(name, options = {}, &block) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/immutabler/dsl/group.rb', line 49 def model(name, = {}, &block) prefix = @prefix + name.to_s base = .fetch(:base, @base_model).to_s base_immutable = .fetch(:base_immutable, false) builder_base = .fetch(:builder_base, base).to_s props = [] ModelAttributesBuilder.new(props, &block) model = Model.new(prefix, base, base_immutable, builder_base, props) models << model end |
#module_link_to(module_name, file_name) ⇒ Object
30 31 32 |
# File 'lib/immutabler/dsl/group.rb', line 30 def module_link_to(module_name, file_name) module_links << ModuleImport.new(module_name, file_name) end |
#output_dir(dir) ⇒ Object
34 35 36 |
# File 'lib/immutabler/dsl/group.rb', line 34 def output_dir(dir) self.output_directory = dir end |