Returns the recipe (meaning all the rules) needed to
 build the custom klass

 @param [ String, Symbol ] name The name of the relation.

 @return [ Array ] An array of hashes
198958
def custom_fields_recipe_for(name)
      {
        'name'     => "#{self.relations[name.to_s].class_name.demodulize}#{self._id}",
        'rules'    => self.ordered_custom_fields(name).map(&:to_recipe),
        'version'  => self.custom_fields_version(name),
        'model_name' => self.relations[name.to_s].class_name.constantize.model_name.to_s
      }
    end
102980
def get_class(name) #:nodoc:
      raise ArgumentError, "class name is blank" if blank?(name)

      response = call_server(:method => :get, :uri => "class/#{@database}/#{name}")
      rslt = process_response(response) do
        raise NotFoundError, 'class not found' if response.body =~ /Invalid class/
      end

      classes = [rslt]
      decorate_classes_with_model(classes)
      clazz = classes[0]
      clazz.extend Orientdb4r::HashExtension
      clazz.extend Orientdb4r::OClass
      unless clazz['properties'].nil? # there can be a class without properties
        clazz.properties.each do |prop|
          prop.extend Orientdb4r::HashExtension
          prop.extend Orientdb4r::Property
        end
      end

      clazz
    end
175425
def [](name)
      name = name.to_s
      entries.detect { |entry| entry.name.to_s == name }
    end
336974
def from_name(cls, relation_name, conversations=None):
        
        if relation_name is None:
            return None
        relation_class = cls._cache.get(relation_name)
        if relation_class:
            return relation_class(relation_name, conversations)
        role, interface = hookenv.relation_to_role_and_interface(relation_name)
        if role and interface:
            relation_class = cls._find_impl(role, interface)
            if relation_class:
                cls._cache[relation_name] = relation_class
                return relation_class(relation_name, conversations)
        return None
933892
def resource_scope # Thing
      @_effective_resource_relation ||= (
        relation = case @_effective_resource_scope  # If this was initialized by the resource_scope before_filter
        when ActiveRecord::Relation
          @_effective_resource_scope
        when Hash
          effective_resource.klass.where(@_effective_resource_scope)
        when Symbol
          effective_resource.klass.send(@_effective_resource_scope)
        when nil
          effective_resource.klass.respond_to?(:all) ? effective_resource.klass.all : effective_resource.klass
        else
          raise "expected resource_scope method to return an ActiveRecord::Relation or Hash"
        end

        unless relation.kind_of?(ActiveRecord::Relation) || effective_resource.active_model?
          raise("unable to build resource_scope for #{effective_resource.klass || 'unknown klass'}. Please name your controller to match an existing model, or manually define a resource_scope.")
        end

        relation
      )
    end
219402
def is_a_custom_field_many_relationship?(name)
      rule = self.custom_fields_recipe['rules'].detect do |rule|
        rule['name'] == name && _custom_field_many_relationship?(rule['type'])
      end
    end
159755
def relation
      return unless @builder
      return unless @builder.object
      return unless @builder.object.relations
      relation = @builder.object.relations[attribute_name.to_s]
      raise "Relation #{attribute_name} not found" unless relation
      relation
    end
1121535
def method_missing(name, *args, &block)
      if self.class.resources.keys.include?(name)
        resources[name] ||= self.class.resources[name].new(self)
        resources[name]
      else
        super
      end
    end
917554
def init_many(hash)
    # generate single_parser
    pattern_element = PatternElement.new(hash[:many], @init_options.merge(name:hash[:as]))

    # generate delimiter_pattern_element
    many_delimiter_pattern_element = hash[:delimiter] && PatternElement.new(hash[:delimiter], @init_options.merge(name:hash[:delimiter_name]))

    # generate many-parser
    self.parser = lambda do |parent_node|
      parent_node.match_name_is_poly(pattern_element.name)

      # fail unless we can match at least one
      return unless parent_node.match pattern_element

      if many_delimiter_pattern_element
        parent_node.match_name_is_poly(many_delimiter_pattern_element.name)
        # delimited matching
        while (parent_node.attempt_match do
            parent_node.match_delimiter &&
            parent_node.match(many_delimiter_pattern_element).tap{|md|md&&md.many_delimiter=true} &&
            parent_node.match_delimiter &&
            parent_node.match(pattern_element)
          end)
        end
      else
        # not delimited matching
        while (parent_node.attempt_match do
            parent_node.match_delimiter &&
            parent_node.match(pattern_element)
          end)
        end
      end
      parent_node
    end
  end
708921
def get_class_by_name!(name , super_class = :Object)
      c = get_class_by_name(name)
      return c if c
      create_class( name ,super_class)
    end
908173
def build
      klass = ResourceClassCache.instance.fetch(pcdm_object) do
        self.class.to_valkyrie_resource_class(klass: pcdm_object.class)
      end
      pcdm_object.id = minted_id if pcdm_object.id.nil?
      attrs = attributes.tap { |hash| hash[:new_record] = pcdm_object.new_record? }
      klass.new(alternate_ids: [::Valkyrie::ID.new(pcdm_object.id)], **attrs)
    end
677679
def build(associations, base_klass)
      associations.map do |name, right|
        if name.is_a? Join
          reflection = find_reflection base_klass, name.name
          reflection.check_validity!
          reflection.check_eager_loadable!

          klass = if reflection.polymorphic?
            name.klass || base_klass
          else
            reflection.klass
          end
          JoinAssociation.new(reflection, build(right, klass), alias_tracker, name.klass, name.type)
        else
          reflection = find_reflection base_klass, name
          reflection.check_validity!
          reflection.check_eager_loadable!

          if reflection.polymorphic?
            raise ActiveRecord::EagerLoadPolymorphicError.new(reflection)
          end
          JoinAssociation.new(reflection, build(right, reflection.klass), alias_tracker)
        end
      end
    end
992979
def recipe(recipe_name, hsh={})
      _recipes << recipe_name unless _recipes.include?(recipe_name)

      head = {}
      tail = head
      recipe_name.split("::").each do |key|
        unless key == "default"
          n = {}
          tail[key] = n
          tail = n
        end
      end
      tail.replace hsh

      override_attributes.merge!(head) unless hsh.empty?
    end
999478
def any_const_get(name)
      return name if name.is_a?(Module)
      begin
        klass = Object
        name.split('::').each {|e|
          klass = klass.const_get(e)
        }
        klass
      rescue
        nil
      end
    end
1372835
def get(self, name=None):
        
        return self.__app.recipes.get(name, self._plugin)
776360
def to_recipe
      method_name       = :"#{self.type}_to_recipe"
      custom_to_recipe  = self.send(method_name) rescue {}

      { 'name'      => self.name,
        'type'      => self.type,
        'required'  => self.required?,
        'unique'    => self.unique?,
        'localized' => self.localized?,
        'default'   => self.default }.merge(custom_to_recipe)
    end
1150522
def precomputed_header_keys_for_rack
      @precomputed_header_keys_for_rack ||= begin
        @headers.attributes.keys.each_with_object(Hash.new) do |key,hash|
          name = key.to_s
          name = "HTTP_#{name.gsub('-','_').upcase}" unless ( name == "CONTENT_TYPE" || name == "CONTENT_LENGTH" )
          hash[name] = key
        end
      end
    end