lib/dato/local/items_repo.rb in dato-0.1.24 vs lib/dato/local/items_repo.rb in dato-0.1.25
- old
+ new
@@ -39,10 +39,18 @@
def item_types
entities_repo.find_entities_of_type('item_type')
end
+ def single_instance_item_types
+ item_types.select(&:singleton)
+ end
+
+ def collection_item_types
+ item_types - single_instance_item_types
+ end
+
def items_of_type(item_type)
method, singleton = item_type_methods[item_type]
if singleton
[@collections_by_type[method]]
@@ -59,11 +67,11 @@
end
def build_item_type_methods!
@item_type_methods = {}
- singleton_keys = singleton_item_types.map(&:api_key)
+ singleton_keys = single_instance_item_types.map(&:api_key)
collection_keys = collection_item_types.map(&:api_key)
.map(&:pluralize)
clashing_keys = singleton_keys & collection_keys
@@ -106,17 +114,9 @@
end
end
def item_entities
entities_repo.find_entities_of_type('item')
- end
-
- def singleton_item_types
- item_types.select(&:singleton)
- end
-
- def collection_item_types
- item_types - singleton_item_types
end
def method_missing(method, *arguments, &block)
if collections_by_type.key?(method) && arguments.empty?
collections_by_type[method]