Sha256: e197ff0b4aed9d92d63428e7a7934977a74fedc3bdb95436e0fdbff8d1bc6754

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module Fluxo
  class Operation
    module Attributes
      def self.included(klass)
        klass.extend(ClassMethods)
      end

      module ClassMethods
        # This variable is used only when ActiveModel is available.
        attr_reader :validations_proxy

        # Auto handle errors/exceptions.
        attr_writer :strict

        def strict?
          return @strict if defined? @strict

          @strict = Fluxo.config.strict?
        end

        def validations
          raise NotImplementedError, "ActiveModel is not defined to use validations."
        end

        def required_attributes
          @required_attributes ||= []
        end

        def validate_attributes(*attributes)
          @required_attributes ||= []
          @required_attributes |= attributes
        end
        alias_method :require_attribute, :validate_attributes
        alias_method :attributes, :validate_attributes

        def transient_attributes(*)
          puts "DEPRECATED: #{__method__} is deprecated. Operation runs on sloppy mode by allowing any transient attribute."
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluxo-0.3.0 lib/fluxo/operation/attributes.rb