lib/basic_serializer/dsl.rb in basic_serializer-0.1.7 vs lib/basic_serializer/dsl.rb in basic_serializer-0.1.8

- old
+ new

@@ -7,27 +7,34 @@ end def attribute(name, type = nil) attributes[name] = type || :default - return if method_defined?(name) + return if @defined_methods&.include?(name) - define_method(name) { object.send(name) } + @defined_methods ||= Set.new + @defined_methods << name + + define_method(name) { object.public_send(name) } end def model_name(name) - @model_name ||= name + @model_name = name end def custom_model_name - @model_name || name.gsub("Serializer", "") + @custom_model_name ||= @model_name || name.delete_suffix("Serializer") end def schema_ref(ref) - @schema_ref ||= ref + @schema_ref = ref end def format(name, pretty: false) - @format ||= { name: name, pretty: pretty } + @format = { name: name, pretty: pretty } + end + + def format_settings + @format_settings ||= {} end end end