Class: NitroKit::SchemaBuilder::Builder
- Inherits:
-
Object
- Object
- NitroKit::SchemaBuilder::Builder
- Defined in:
- lib/nitro_kit/schema_builder.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #add(name, components: nil, helpers: nil, js: [], modules: [], gems: []) ⇒ Object
- #all ⇒ Object
-
#initialize {|_self| ... } ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize {|_self| ... } ⇒ Builder
Returns a new instance of Builder.
6 7 8 9 |
# File 'lib/nitro_kit/schema_builder.rb', line 6 def initialize @schema = {} yield self end |
Instance Method Details
#[](key) ⇒ Object
34 35 36 |
# File 'lib/nitro_kit/schema_builder.rb', line 34 def [](key) @schema[key] end |
#add(name, components: nil, helpers: nil, js: [], modules: [], gems: []) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/nitro_kit/schema_builder.rb', line 11 def add( name, components: nil, helpers: nil, js: [], modules: [], gems: [] ) # Default is one component, one helper with same name components ||= [name] helpers ||= [name] @schema[name] = Component.new( [ components.map { |c| "app/components/nitro_kit/#{c}.rb" }, helpers.map { |c| "app/helpers/nitro_kit/#{c}_helper.rb" }, js.map { |c| "app/javascript/controllers/nk/#{c}_controller.js" } ].flatten, modules, gems ) end |
#all ⇒ Object
38 39 40 |
# File 'lib/nitro_kit/schema_builder.rb', line 38 def all @schema.keys.map(&:to_s) end |