Sha256: 492dab5d9ae3be309e7d2c250336c8d1fd7ddcd3096ded8d934dd406c4e280ae

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require "democritus/version"
require 'democritus/class_builder'
require 'democritus/class_builder/commands'
require 'democritus/from_json_class_builder'

# Compose objects by leveraging a DSL for class creation.
# Yes, we can write code that conforms to interfaces, but in my experience, as the Ruby object ecosystem has grown, so too has the needs
# for understanding the galaxy of objects.
module Democritus
  # @api public
  #
  # Responsible for building a class based on atomic components.
  #
  # @yield [Democritus::ClassBuilder] Gives a builder to provide additional command style customizations
  # @return Class
  def self.build(&configuration_block)
    builder = ClassBuilder.new
    builder.customize(&configuration_block)
    builder.generate_class
  end

  # @api public
  #
  # Responsible for building a class based on the given JSON object.
  #
  # @return Class
  def self.build_from_json(json)
    builder = FromJsonClassBuilder.new(json)
    builder.generate_class
  end

  # An empty module intended to be exposed for is_a? comparisons (and ==)
  #
  # @example
  #   AnotherClass = Democritus.build
  #   assert_equal true, AnotherClass.new.is_a?(Democritus::DemocritusObjectTag)
  module DemocritusObjectTag
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
democritus-0.2.0 lib/democritus.rb