def build
      # return if already built
      return @klass unless @klass.nil?

      # need the class name to build class
      return nil    if @klass_name.nil?

      # return if we can find constant corresponding to class name
      already_defined = eval("defined?(#{@klass_name}) == 'constant' and #{@klass_name}.class == Class")
      if already_defined
        @klass = @klass_name.constantize
        return @klass
      end

      if @namespace
        namespaces = @namespace.split(/\.|::/)

        namespaces.each_with_index do |ns, index|
          if index == 0
            next if Object.const_defined? ns
            Object.const_set(ns, Module.new)
          else
            current_ns = namespaces[0..index-1].join '::'
            next if eval "#{current_ns}.const_defined? '#{ns}'"
            eval "#{current_ns}.const_set('#{ns}', Module.new)"
          end
        end

        klass_constant = @klass_name.split('::').last
        eval "#{namespaces.join '::'}.const_set('#{klass_constant}', Class.new.extend(ActiveSupport::JSON))"
      else
        Object.const_set(@klass_name, Class.new.extend(ActiveSupport::JSON))
      end

      @klass = @klass_name.constantize
      @klass.class_eval do
        include OData
      end

      add_initializer(@klass)
      add_methods(@klass)
      add_nav_props(@klass)
      add_class_methods(@klass)

      return @klass
    end
def build
      # return if already built
      return @klass unless @klass.nil?

      # need the class name to build class
      return nil    if @klass_name.nil?

      # return if we can find constant corresponding to class name
      already_defined = eval("defined?(#{@klass_name}) == 'constant' and #{@klass_name}.class == Class")
      if already_defined
        @klass = @klass_name.constantize
        return @klass
      end

      if @namespace
        namespaces = @namespace.split(/\.|::/)

        namespaces.each_with_index do |ns, index|
          if index == 0
            next if Object.const_defined? ns
            Object.const_set(ns, Module.new)
          else
            current_ns = namespaces[0..index-1].join '::'
            next if eval "#{current_ns}.const_defined? '#{ns}'"
            eval "#{current_ns}.const_set('#{ns}', Module.new)"
          end
        end

        klass_constant = @klass_name.split('::').last
        eval "#{namespaces.join '::'}.const_set('#{klass_constant}', Class.new.extend(ActiveSupport::JSON))"
      else
        Object.const_set(@klass_name, Class.new.extend(ActiveSupport::JSON))
      end

      @klass = @klass_name.constantize
      @klass.class_eval do
        include OData
      end

      add_initializer(@klass)
      add_methods(@klass)
      add_nav_props(@klass)
      add_class_methods(@klass)

      return @klass
    end
Creates a new instance of the ClassBuilder class

 @param [String] klass_name the name/type of the class to create
 @param [Array] methods the accessor methods to add to the class
 @param [Array] nav_props the accessor methods to add for navigation properties
 @param [Service] context the service context that this entity belongs to
 @param [String, nil] namespace optional namespace to create the classes in
 Returns a dynamically generated class definition based on the constructor parameters