module JSON::SchemaDsl::AstNode
Methods for an object to be used as an ast node by the renderer Include this module to define your own types that are not descendants of Entity
. You should still implement two methods to be compatible with the normal builder class:
initialize: Hash -> Self to_h: Self -> Hash .has_attribute?: Symbol -> Boolean
Public Class Methods
included(base)
click to toggle source
# File lib/json/schema_dsl/ast_node.rb, line 14 def self.included(base) base.extend(ClassMethods) end
Public Instance Methods
render()
click to toggle source
Used to do a simple render of the entity. Since this has no sensible scope while
rendering, use Builder#render instead.
@see JSON::SchemaDsl::Builder#render
# File lib/json/schema_dsl/ast_node.rb, line 29 def render ::JSON::SchemaDsl::Renderer.new(self).render end
update(attribute_name, value = nil)
click to toggle source
@param [Symbol] attribute_name The name of the attribute to update. @param [Object] value The value that will be set for the attribute. @return [Entity] Since entities themselves are immutable, this method returns a new
entity with the attribute_name and value pair added.
# File lib/json/schema_dsl/ast_node.rb, line 22 def update(attribute_name, value = nil) self.class.new(to_h.merge(attribute_name => value)) end