lib/transcriber/resource/builder.rb in transcriber-0.0.25 vs lib/transcriber/resource/builder.rb in transcriber-0.0.26
- old
+ new
@@ -1,11 +1,30 @@
module Transcriber
class Resource
module Builder
- include Keys
- include Relations
- include Embeddables
- include Properties
- include Summarizations
+ 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