module Contentful::DatabaseImporter::ResourceClassMethods

Class Methods for Resource

Attributes

id_generator[RW]

Public Instance Methods

all() click to toggle source
# File lib/contentful/database_importer/resource_class_methods.rb, line 71
def all
  entries = []
  rows = if query.nil?
           table.all
         else
           table.where(query).all
         end

  rows.each_with_index do |row, index|
    entries << new(row, index)
  end

  entries
end
content_type_id() click to toggle source
# File lib/contentful/database_importer/resource_class_methods.rb, line 16
def content_type_id
  @content_type_id || Support.snake_case(name)
end
content_type_id=(ct_id) click to toggle source
# File lib/contentful/database_importer/resource_class_methods.rb, line 20
def content_type_id=(ct_id)
  @content_type_id = ct_id
end
content_type_name() click to toggle source
# File lib/contentful/database_importer/resource_class_methods.rb, line 24
def content_type_name
  (@content_type_name || name)
end
content_type_name=(name) click to toggle source
# File lib/contentful/database_importer/resource_class_methods.rb, line 28
def content_type_name=(name)
  @content_type_name = name
end
default_generator_options() click to toggle source
# File lib/contentful/database_importer/resource_class_methods.rb, line 40
def default_generator_options
  {
    table_name: table_name,
    content_type_id: content_type_id,
    class_name: name,
    template: '{{content_type_id}}_{{index}}'
  }
end
display_field() click to toggle source
# File lib/contentful/database_importer/resource_class_methods.rb, line 55
def display_field
  default_display_field = fields.reject { |f| f[:exclude_from_output] }.find do |f|
    f[:type] == :string || f[:type] == :symbol
  end || {}

  @display_field || default_display_field[:maps_to]
end
display_field=(field_name) click to toggle source
# File lib/contentful/database_importer/resource_class_methods.rb, line 63
def display_field=(field_name)
  @display_field = field_name
end
id(id_generator_class, options = {}) click to toggle source
# File lib/contentful/database_importer/resource_class_methods.rb, line 49
def id(id_generator_class, options = {})
  @id_generator = id_generator_class.new(
    default_generator_options.merge(options)
  )
end
query() click to toggle source
# File lib/contentful/database_importer/resource_class_methods.rb, line 32
def query
  @query
end
query=(query) click to toggle source
# File lib/contentful/database_importer/resource_class_methods.rb, line 36
def query=(query)
  @query = query
end
table() click to toggle source
# File lib/contentful/database_importer/resource_class_methods.rb, line 67
def table
  Contentful::DatabaseImporter.database[table_name]
end
table_name() click to toggle source
# File lib/contentful/database_importer/resource_class_methods.rb, line 8
def table_name
  (@table_name || Support.snake_case(name)).to_sym
end
table_name=(name) click to toggle source
# File lib/contentful/database_importer/resource_class_methods.rb, line 12
def table_name=(name)
  @table_name = name
end