lib/fluxo/active_model_extension.rb in fluxo-0.2.1 vs lib/fluxo/active_model_extension.rb in fluxo-0.3.0

- old
+ new

@@ -1,5 +1,6 @@ +require 'ostruct' module Fluxo module ActiveModelExtension module ClassMethods def validations(&block) @@ -18,11 +19,11 @@ end private def build_validations_proxy! - validator = Class.new do + validator = Class.new(OpenStruct) do include ActiveModel::Validations def self.validate!(operation_instance, **attrs) validator = new @@ -42,13 +43,15 @@ errors.empty? end end validator.class_eval <<-RUBY, __FILE__, __LINE__ + 1 - attr_accessor #{attribute_names.map(&:inspect).join(", ")} + def self.name + "#{name || 'Fluxo::Operation'}::Validations" + end - def self.model_name - ::ActiveModel::Name.new(self, nil, %|#{name || "Anonymous"}|) + def self.to_s + name end RUBY validator end