Sha256: 78d426056ea6d7ad492d98f856cbae1fc5388673c35f3d49b162d9bb25e8cf7a

Contents?: true

Size: 688 Bytes

Versions: 12

Compression:

Stored size: 688 Bytes

Contents

class RestModel
  class Key
    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)
        RestModel.not_allowed_names.include?(key.name.to_s)
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rest_model-0.1.11 lib/rest_model/key/builder.rb
rest_model-0.1.10 lib/rest_model/key/builder.rb
rest_model-0.1.9 lib/rest_model/key/builder.rb
rest_model-0.1.8 lib/rest_model/key/builder.rb
rest_model-0.1.7 lib/rest_model/key/builder.rb
rest_model-0.1.6 lib/rest_model/key/builder.rb
rest_model-0.1.5 lib/rest_model/key/builder.rb
rest_model-0.1.4 lib/rest_model/key/builder.rb
rest_model-0.1.3 lib/rest_model/key/builder.rb
rest_model-0.1.2 lib/rest_model/key/builder.rb
rest_model-0.1.1 lib/rest_model/key/builder.rb
rest_model-0.1.0 lib/rest_model/key/builder.rb