module Paradocs::Struct

Attributes

_graph[R]
_results[R]

Public Class Methods

included(base) click to toggle source
# File lib/paradocs/struct.rb, line 16
def self.included(base)
  base.send(:include, Paradocs::DSL)
  base.extend ClassMethods
end
new(attrs = {}, environment = {}) click to toggle source
# File lib/paradocs/struct.rb, line 21
def initialize(attrs = {}, environment = {})
  @_results = self.class.schema.resolve(attrs, environment)
  @_graph = self.class.build(@_results.output)
end

Public Instance Methods

==(other) click to toggle source
# File lib/paradocs/struct.rb, line 39
def ==(other)
  other.respond_to?(:to_h) && other.to_h.eql?(to_h)
end
errors() click to toggle source
# File lib/paradocs/struct.rb, line 30
def errors
  _results.errors
end
merge(attrs = {}) click to toggle source
# File lib/paradocs/struct.rb, line 43
def merge(attrs = {})
  self.class.new(to_h.merge(attrs))
end
to_h() click to toggle source

 returns a shallow copy.

# File lib/paradocs/struct.rb, line 35
def to_h
  _results.output.clone
end
valid?() click to toggle source
# File lib/paradocs/struct.rb, line 26
def valid?
  !_results.errors.any?
end