Sha256: 1ce3db97a673de66be7d4afda3eb47e5adeb1506b26fc6b2bcc808bcc70c7575

Contents?: true

Size: 695 Bytes

Versions: 1

Compression:

Stored size: 695 Bytes

Contents

module Transcriber
  class Resource
    module Builder
      include Relation::Builder
      include Embeddable::Builder
      include Property::Builder

      def key(key)
        fail "you can't define a key with name '#{key.name}'" if not_allowed?(key)
        key.model = self
        attr_accessor key.name
        self.keys  << key
        self.id_key = key if key.options[:id]
      end

      def summarizes(*args)
        args.each do |name|
          key = keys.find {|key| key.name == name}
          summarized_keys << key if key
        end
      end

      private

      def not_allowed?(key)
        Resource.not_allowed_names.include?(key.name.to_s)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transcriber-0.0.26 lib/transcriber/resource/builder.rb