Sha256: a6c0e48785780604b9016ec01496684f8b0e07a600e18ec16a0e5e6a82966f51

Contents?: true

Size: 599 Bytes

Versions: 11

Compression:

Stored size: 599 Bytes

Contents

# frozen_string_literal: true

module LedgerSync
  module Domains
    class Operation
      class Resource
        include LedgerSync::Domains::Operation::Mixin

        def resource_class
          @resource_class ||= inferred_resource_class
        end

        private

        def inferred_resource_class
          name = self.class.to_s.split('::')
          name.pop # remove serializer/operation class from name
          resource = name.pop.singularize # pluralized resource module name

          self.class.const_get((name + [resource]).join('::'))
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ledger_sync-domains-1.0.5 lib/ledger_sync/domains/operation/resource.rb
ledger_sync-domains-1.0.4 lib/ledger_sync/domains/operation/resource.rb
ledger_sync-domains-1.0.3 lib/ledger_sync/domains/operation/resource.rb
ledger_sync-domains-1.0.2 lib/ledger_sync/domains/operation/resource.rb
ledger_sync-domains-1.0.1 lib/ledger_sync/domains/operation/resource.rb
ledger_sync-domains-1.0.0 lib/ledger_sync/domains/operation/resource.rb
ledger_sync-domains-1.0.0.rc10 lib/ledger_sync/domains/operation/resource.rb
ledger_sync-domains-1.0.0.rc9 lib/ledger_sync/domains/operation/resource.rb
ledger_sync-domains-1.0.0.rc8 lib/ledger_sync/domains/operation/resource.rb
ledger_sync-domains-1.0.0.rc7 lib/ledger_sync/domains/operation/resource.rb
ledger_sync-domains-1.0.0.rc6 lib/ledger_sync/domains/operation/resource.rb