Class: Graphiti::HashRenderer
Instance Method Summary collapse
-
#initialize(resource, graphql: false) ⇒ HashRenderer
constructor
A new instance of HashRenderer.
- #render(options) ⇒ Object
Constructor Details
#initialize(resource, graphql: false) ⇒ HashRenderer
Returns a new instance of HashRenderer.
134 135 136 137 |
# File 'lib/graphiti/hash_renderer.rb', line 134 def initialize(resource, graphql: false) @resource = resource @graphql = graphql end |
Instance Method Details
#render(options) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/graphiti/hash_renderer.rb', line 139 def render() serializers = [:data] opts = .slice(:fields, :include) opts[:graphql] = @graphql top_level_key = get_top_level_key(@resource, serializers.is_a?(Array)) hash = {top_level_key => {}} nodes = get_nodes(serializers, opts) add_nodes(hash, top_level_key, , nodes, @graphql) add_stats(hash, top_level_key, , @graphql) if @graphql add_page_info(hash, serializers, top_level_key, ) end hash end |