lib/rooftop/models/taxonomy.rb in rooftop-0.0.7.4 vs lib/rooftop/models/taxonomy.rb in rooftop-0.1.1

- old
+ new

@@ -1,8 +1,27 @@ module Rooftop class Taxonomy include Rooftop::Base - collection_path "taxonomies" + self.api_version = 2 + self.api_namespace = "wp" + self.api_endpoint = "taxonomies" + primary_key "slug" - has_many :terms, class_name: "Rooftop::TaxonomyTerm" + + def self.all + taxonomies = [] + get_raw(self.collection_path) do |parsed, raw| + parsed[:data].each do |tax,data| + taxonomies << Taxonomy.new(data) + end + end + taxonomies.each do |t| + t.run_callbacks(:find) + end + return taxonomies + end + + def terms + TaxonomyTerm.get(resource_links.find_by(link_type: "wp:items").first.href) + end end -end \ No newline at end of file +end