lib/democritus/class_builder/commands/attribute.rb in democritus-0.2.0 vs lib/democritus/class_builder/commands/attribute.rb in democritus-0.2.1

- old
+ new

@@ -3,18 +3,25 @@ module Democritus class ClassBuilder module Commands # Command to assign an attribute to the given built class. class Attribute < ::Democritus::ClassBuilder::Command + # @param builder [#defer, Democritus::ClassBuilder] + # @param name [#to_sym] The name of the attribute + # @param options [Hash] The configuration options of the attribute def initialize(name:, **options) self.builder = options.fetch(:builder) self.name = name self.options = options end - attr_reader :name, :options + attr_reader :name + attr_reader :options + # Generate the code for the attribute + # + # @return void # :reek:NestedIterators: { exclude: [ 'Democritus::ClassBuilder::Commands::Attribute#call' ] } def call defer do |subject| subject.module_exec(@name) do |name| attr_reader name @@ -24,10 +31,14 @@ end end private - attr_writer :name, :options + attr_writer :options + + def name=(input) + @name = input.to_sym + end end end end end