Class: Dslable::Generators::ProductCodes::DslModel
- Inherits:
-
Object
- Object
- Dslable::Generators::ProductCodes::DslModel
- Defined in:
- lib/generators/product_codes/dsl_model.rb
Constant Summary collapse
- DSL_MODEL_TEMPLATE =
"# encoding: utf-8\nrequire 'active_model'\n\nmodule <%=gem_name_camel%>\n class DslModel\ninclude ActiveModel::Model\n\n<%=fields%>\n end\nend\n"
Instance Attribute Summary collapse
-
#dsl ⇒ Object
Returns the value of attribute dsl.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(_dsl) ⇒ DslModel
constructor
initialize dsl model === Params - _dsl: input from dsl.
Constructor Details
#initialize(_dsl) ⇒ DslModel
initialize dsl model
Params
-
_dsl: input from dsl
27 28 29 30 |
# File 'lib/generators/product_codes/dsl_model.rb', line 27 def initialize(_dsl) raise InvalidDslError.new("dsl not allow nil") if _dsl.nil? @dsl = _dsl end |
Instance Attribute Details
#dsl ⇒ Object
Returns the value of attribute dsl.
22 23 24 |
# File 'lib/generators/product_codes/dsl_model.rb', line 22 def dsl @dsl end |
Instance Method Details
#generate ⇒ Object
32 33 34 35 |
# File 'lib/generators/product_codes/dsl_model.rb', line 32 def generate dsl_model_src = adapt_template(@dsl.camelized_gem_name, get_fields) generate_dsl_model_src dsl_model_src end |