Sha256: 7a38780836668170d105b61bc01281e192c7a17eb3369c12fcb64e0595561a90

Contents?: true

Size: 803 Bytes

Versions: 4

Compression:

Stored size: 803 Bytes

Contents

module Eco
  module API
    module Common
      module Loaders
        class CaseBase < Loaders::Base
          class << self
            attr_writer :name, :type

            # The name that this case, policy or error handler will have.
            def name(value = nil)
              name_only_once! if value
              set_created_at!
              return @name ||= self.to_s unless value
              @name = value
            end

            # Prevent the same class to be re-opened/re-named
            def name_only_once!
              raise "You have already declared #{self} or you are trying to give it a name twice" if @name
            end
          end

          def name
            self.class.name
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eco-helpers-2.6.4 lib/eco/api/common/loaders/case_base.rb
eco-helpers-2.6.3 lib/eco/api/common/loaders/case_base.rb
eco-helpers-2.6.2 lib/eco/api/common/loaders/case_base.rb
eco-helpers-2.6.1 lib/eco/api/common/loaders/case_base.rb