lib/transcriber/resource.rb in transcriber-0.0.14 vs lib/transcriber/resource.rb in transcriber-0.0.15
- old
+ new
@@ -1,9 +1,10 @@
module Transcriber
class Resource
extend Builder
extend Parser
+ include InputParser
include Response
include Serialization
cattr_accessor :id_key
cattr_writer :resource_name
@@ -48,35 +49,8 @@
puts "warning: redefining '#{method_name}' may cause serious problems"
end
def self.not_allowed_names
%w(resource_id resource link)
- end
-
- def to_input(options = {})
- input = {}
- keys_to_input(options).each do |key|
- value = __send__("#{key.name}")
- parsed_value = key.to_input(value, options.fetch(key.name, {}))
- path = key.input_path
-
- if path.any?
- last = path.pop
- key_input = path.inject(input) {|buffer, key| buffer[key] = {}; buffer[key]}
- key_input[last] = parsed_value
- else
- input.merge!(parsed_value)
- end
- 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)} unless options.fetch(:relations, true)
- keys.reject! {|k| Array(options[:without]).include?(k.name)}
- end
end
end
end