Sha256: 428f8cc4e8b42b3640707799144137066c15f99691fdebde850b3326258d7e38

Contents?: true

Size: 793 Bytes

Versions: 17

Compression:

Stored size: 793 Bytes

Contents

# frozen_string_literal: true

module IronBank
  # Metadata to provide accessors to Zuora resources.
  #
  module Metadata
    # Can be overriden to exclude specific fields for a given resource, see
    # `Account` class for an example
    def exclude_fields
      []
    end

    def fields
      return [] unless schema

      @fields ||= schema.fields.map(&:name) - exclude_fields
    end

    def query_fields
      return [] unless schema

      @query_fields ||= schema.query_fields - exclude_fields
    end

    def schema
      @schema ||= IronBank::Schema.for(object_name)
    end

    def with_schema
      fields.each do |field|
        field_name = IronBank::Utils.underscore(field).to_sym
        define_method(:"#{field_name}") { remote[field_name] }
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
iron_bank-3.4.0 lib/iron_bank/metadata.rb
iron_bank-3.3.4 lib/iron_bank/metadata.rb
iron_bank-3.3.3 lib/iron_bank/metadata.rb
iron_bank-3.3.2 lib/iron_bank/metadata.rb
iron_bank-3.3.1 lib/iron_bank/metadata.rb
iron_bank-3.3.0 lib/iron_bank/metadata.rb
iron_bank-3.2.0 lib/iron_bank/metadata.rb
iron_bank-3.1.1 lib/iron_bank/metadata.rb
iron_bank-3.1.0 lib/iron_bank/metadata.rb
iron_bank-3.0.3 lib/iron_bank/metadata.rb
iron_bank-3.0.2 lib/iron_bank/metadata.rb
iron_bank-3.0.1 lib/iron_bank/metadata.rb
iron_bank-3.0.0 lib/iron_bank/metadata.rb
iron_bank-2.2.0 lib/iron_bank/metadata.rb
iron_bank-2.1.0 lib/iron_bank/metadata.rb
iron_bank-2.0.2 lib/iron_bank/metadata.rb
iron_bank-2.0.1 lib/iron_bank/metadata.rb