Sha256: 9758221f6dda114dc49be99fc3ca201f5eca45e18119871d7b9d7d8f45ad9b56

Contents?: true

Size: 581 Bytes

Versions: 2

Compression:

Stored size: 581 Bytes

Contents

module Transcriber
  class Resource
    module InputParser
      def to_input(options = {})
        input = {}

        keys_to_input(options).each do |key|
          value = __send__(key.name)
          input.merge! key.to_input(value, options.fetch(key.name, {}))
        end

        input.with_indifferent_access
      end

      private

      def keys_to_input(options)
        self.class.keys.clone.tap do |keys|
          keys.reject! {|k| k.kind_of?(Relation)}
          keys.reject! {|k| Array(options[:without]).include?(k.name)}
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
transcriber-0.0.19 lib/transcriber/resource/input_parser.rb
transcriber-0.0.18 lib/transcriber/resource/input_parser.rb