Class: RbsActiverecord::Generator::Enum::Mappings
- Defined in:
- lib/rbs_activerecord/generator/enum/mappings.rb
Instance Attribute Summary collapse
-
#declarations ⇒ Object
readonly
: Array.
-
#model ⇒ Object
readonly
: RbsActiverecord::Model.
Instance Method Summary collapse
-
#generate ⇒ Object
: String.
-
#initialize(model, declarations) ⇒ Mappings
constructor
A new instance of Mappings.
Constructor Details
#initialize(model, declarations) ⇒ Mappings
Returns a new instance of Mappings.
12 13 14 15 16 17 |
# File 'lib/rbs_activerecord/generator/enum/mappings.rb', line 12 def initialize(model, declarations) #: void @model = model @declarations = declarations.fetch(model.klass.name.to_s, []) super() end |
Instance Attribute Details
#declarations ⇒ Object (readonly)
: Array
8 9 10 |
# File 'lib/rbs_activerecord/generator/enum/mappings.rb', line 8 def declarations @declarations end |
#model ⇒ Object (readonly)
: RbsActiverecord::Model
7 8 9 |
# File 'lib/rbs_activerecord/generator/enum/mappings.rb', line 7 def model @model end |
Instance Method Details
#generate ⇒ Object
: String
19 20 21 22 23 24 25 |
# File 'lib/rbs_activerecord/generator/enum/mappings.rb', line 19 def generate #: String <<~RBS.strip module GeneratedEnumMappingMethods #{enums.map { |node| enum(node) }.join("\n")} end RBS end |