Sha256: e862c3d7ac0967b620a4dd23483a12fb8e6afd757ae11d394bc252a76ae8b545

Contents?: true

Size: 812 Bytes

Versions: 46

Compression:

Stored size: 812 Bytes

Contents

module Access
  class Category

    def self.search(options = {})
      Access::Api.new.search_categories options
    end

    def self.find(category_key, options = {})
      Access::Api.new.find_category category_key, options
    end

    def self.process_batch(chunk)
      chunk.map { |category| new(category) }
    end

    def initialize(values)
      self.class.class_eval {attr_reader *values.keys }
      values.each do |attribute_name, attribute_value|
        self.instance_variable_set("@#{attribute_name}", attribute_value)
      end
      @links = Access::Link.new(@links) if @links
      @subcategories = Access::Category.process_batch(@subcategories) if @subcategories
      @subcategory_siblings = Access::Category.process_batch(@subcategory_siblings) if @subcategory_siblings
    end

  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
access-2.0.50 lib/access/category.rb
access-2.0.49 lib/access/category.rb
access-2.0.48 lib/access/category.rb
access-2.0.47 lib/access/category.rb
access-2.0.46 lib/access/category.rb
access-2.0.44 lib/access/category.rb
access-2.0.43 lib/access/category.rb
access-2.0.42 lib/access/category.rb
access-2.0.41 lib/access/category.rb
access-2.0.40 lib/access/category.rb
access-2.0.39 lib/access/category.rb
access-2.0.38 lib/access/category.rb
access-2.0.37 lib/access/category.rb
access-2.0.36 lib/access/category.rb
access-2.0.34 lib/access/category.rb
access-2.0.33 lib/access/category.rb
access-2.0.32 lib/access/category.rb
access-2.0.31 lib/access/category.rb
access-2.0.30 lib/access/category.rb
access-2.0.29 lib/access/category.rb