Module: Algebrick

Extended by:
Helper, Matching
Includes:
Matching, Types
Defined in:
lib/algebrick.rb,
lib/algebrick/dsl.rb,
lib/algebrick/type.rb,
lib/algebrick/atom.rb,
lib/algebrick/types.rb,
lib/algebrick/value.rb,
lib/algebrick/reclude.rb,
lib/algebrick/matching.rb,
lib/algebrick/matchers.rb,
lib/algebrick/protocol.rb,
lib/algebrick/serializer.rb,
lib/algebrick/type_check.rb,
lib/algebrick/matchers/or.rb,
lib/algebrick/serializers.rb,
lib/algebrick/matchers/and.rb,
lib/algebrick/matchers/any.rb,
lib/algebrick/matchers/not.rb,
lib/algebrick/matchers/atom.rb,
lib/algebrick/matchers/many.rb,
lib/algebrick/matchers/array.rb,
lib/algebrick/product_variant.rb,
lib/algebrick/matchers/wrapper.rb,
lib/algebrick/matchers/product.rb,
lib/algebrick/matchers/variant.rb,
lib/algebrick/matchers/abstract.rb,
lib/algebrick/serializers/chain.rb,
lib/algebrick/parametrized_type.rb,
lib/algebrick/serializers2/chain.rb,
lib/algebrick/matcher_delegations.rb,
lib/algebrick/serializers/to_json.rb,
lib/algebrick/field_method_readers.rb,
lib/algebrick/serializers/abstract.rb,
lib/algebrick/serializers2/to_json.rb,
lib/algebrick/product_constructors.rb,
lib/algebrick/serializers2/abstract.rb,
lib/algebrick/matchers/abstract_logic.rb,
lib/algebrick/product_constructors/basic.rb,
lib/algebrick/serializers/strict_to_hash.rb,
lib/algebrick/product_constructors/named.rb,
lib/algebrick/serializers2/strict_to_hash.rb,
lib/algebrick/serializers/abstract_to_hash.rb,
lib/algebrick/product_constructors/abstract.rb,
lib/algebrick/serializers2/abstract_to_hash.rb,
lib/algebrick/serializers/benevolent_to_hash.rb,
lib/algebrick/serializers2/benevolent_to_hash.rb

Overview

Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Modules: DSL, FieldMethodReaders, Helper, MatcherDelegations, Matchers, Matching, ProductConstructors, Reclude, Serializers, Serializers2, TypeCheck, Types, Value Classes: Atom, ParametrizedType, ProductVariant, Protocol, Serializer, Type

Constant Summary

AsJson =
protocol :asjson

Constants included from Types

Types::Boolean, Types::LinkedList, Types::Maybe

Class Method Summary (collapse)

Methods included from Helper

protocol

Methods included from Matching

any, match, match_value, on

Class Method Details

+ (Object) atom



96
97
98
# File 'lib/algebrick/dsl.rb', line 96

def self.atom
  Atom.new nil
end

+ (Object) type(*variables, &block)



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/algebrick/dsl.rb', line 83

def self.type(*variables, &block)
  if block.nil?
    raise 'Atom cannot be parametrized' unless variables.empty?
    atom
  else
    if variables.empty?
      DSL::TypeDefinitionScope.new(ProductVariant.new(nil), &block).new_type
    else
      DSL::TypeDefinitionScope.new(ParametrizedType.new(variables), &block).new_type
    end
  end
end

+ (Object) types(&block)



100
101
102
# File 'lib/algebrick/dsl.rb', line 100

def self.types(&block)
  DSL::OuterShell.new &block
end

+ (Object) version



31
32
33
# File 'lib/algebrick.rb', line 31

def self.version
  @version ||= Gem::Version.new File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
end