Sha256: 023884374d90d3660a7ca494f7d1c39e70b53f71d60335509818aa36bad02cc7

Contents?: true

Size: 629 Bytes

Versions: 1

Compression:

Stored size: 629 Bytes

Contents

module Id
  module Model

    attr_reader :data

    def initialize(data)
      @data = Hash[data.map { |k, v| [k.to_s, v] }]
    end

    def self.included(base)
      base.extend(Descriptor)
    end

    private

    def memoize(f, &b)
      instance_variable_get("@#{f}") || instance_variable_set("@#{f}", b.call)
    end

    module Descriptor
      def field(f, options={})
        Field.new(self, f, options).define
      end

      def has_one(f, options={})
        HasOne.new(self, f, options).define
      end

      def has_many(f, options={})
        HasMany.new(self, f, options).define
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
id-0.0.1 lib/id/model.rb