Sha256: 29875f89261b3a0693ebeed6c012433cbc5741b5f139dfb89096b70c16d94edf

Contents?: true

Size: 554 Bytes

Versions: 1

Compression:

Stored size: 554 Bytes

Contents

# frozen_string_literal: true

class WCC::Contentful::Model
  extend WCC::Contentful::Helpers
  extend WCC::Contentful::ModelValidators

  class << self
    attr_accessor :store
  end

  def self.all_models
    WCC::Contentful::Model.constants(false).map { |k| WCC::Contentful::Model.const_get(k) }
  end

  def self.find(id, context = nil)
    return unless raw = store.find(id)

    content_type = content_type_from_raw(raw)

    const = WCC::Contentful::Model.const_get(constant_from_content_type(content_type))
    const.new(raw, context)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wcc-contentful-0.1.0 lib/wcc/contentful/model.rb