Sha256: e63ca439a24609e942de5b6488b6942de3a1ae75e7bfa74da9b1d2e3450f1252
Contents?: true
Size: 964 Bytes
Versions: 2
Compression:
Stored size: 964 Bytes
Contents
module FactoryHelper include ResourceHelper def create_tree(*names) operations = names.last.is_a?(Hash) ? names.pop : {} root = build_root leaf = names.inject(root) do |parent, object| if object.is_a?(Array) name, only = *object node = build_collection(name, only: only) else name = object node = build_collection(name) end parent.append(node) node end operations.each do |name, action| on = restful_member_actions.include?(action) ? :member : :collection operation = build_operation(name, action: action, on: on) leaf.append(operation) end root end private def build_root(*arguments) Apitizer::Routing::Node::Root.new(*arguments) end def build_collection(*arguments) Apitizer::Routing::Node::Collection.new(*arguments) end def build_operation(*arguments) Apitizer::Routing::Node::Operation.new(*arguments) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
apitizer-0.0.3 | spec/support/factory_helper.rb |
apitizer-0.0.2 | spec/support/factory_helper.rb |