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.
127 128 129 130 |
# File 'lib/graphiti/hash_renderer.rb', line 127 def initialize(resource, graphql: false) @resource = resource @graphql = graphql end |
Instance Method Details
#render(options) ⇒ Object
132 133 134 135 136 137 138 139 |
# File 'lib/graphiti/hash_renderer.rb', line 132 def render() serializers = [:data] opts = .slice(:fields, :include) opts[:graphql] = @graphql to_hash(serializers, opts).tap do |hash| hash.merge!(.slice(:meta)) unless [:meta].empty? end end |