lib/fluxo/operation/attributes.rb in fluxo-0.2.1 vs lib/fluxo/operation/attributes.rb in fluxo-0.3.0
- old
+ new
@@ -6,63 +6,38 @@
def self.included(klass)
klass.extend(ClassMethods)
end
module ClassMethods
+ # This variable is used only when ActiveModel is available.
attr_reader :validations_proxy
- # When set to true, the operation will not validate the transient_attributes defition during the flow step execution.
- attr_writer :strict_transient_attributes
+ # Auto handle errors/exceptions.
+ attr_writer :strict
- # When set to true, the operation will not validate attributes definition before calling the operation.
- attr_writer :strict_attributes
+ def strict?
+ return @strict if defined? @strict
- def strict_attributes?
- return @strict_attributes if defined?(@strict_attributes)
-
- Fluxo.config.strict_attributes
+ @strict = Fluxo.config.strict?
end
- def strict_transient_attributes?
- return @strict_transient_attributes if defined?(@strict_transient_attributes)
-
- Fluxo.config.strict_transient_attributes
- end
-
def validations
raise NotImplementedError, "ActiveModel is not defined to use validations."
end
- def attribute_names
- @attribute_names ||= []
+ def required_attributes
+ @required_attributes ||= []
end
- def transient_attribute_names
- @transient_attribute_names ||= []
+ def validate_attributes(*attributes)
+ @required_attributes ||= []
+ @required_attributes |= attributes
end
+ alias_method :require_attribute, :validate_attributes
+ alias_method :attributes, :validate_attributes
- def attributes(*names)
- @attribute_names ||= []
- names = names.map(&:to_sym) - @attribute_names
- @attribute_names.push(*names)
- end
-
- def transient_attributes(*names)
- @transient_attribute_names ||= []
- names = names.map(&:to_sym) - @transient_attribute_names
- @transient_attribute_names.push(*names)
- end
-
- def attribute?(key)
- return false unless key
-
- attribute_names.include?(key.to_sym)
- end
-
- def transient_attribute?(key)
- return false unless key
-
- transient_attribute_names.include?(key.to_sym)
+ def transient_attributes(*)
+ puts "DEPRECATED: #{__method__} is deprecated. Operation runs on sloppy mode by allowing any transient attribute."
end
end
end
end
end