class Releaf::Content::Configuration

Public Instance Methods

controller_names() click to toggle source
# File lib/releaf/content/configuration.rb, line 46
def controller_names
  @controller_names ||=  resources.values.map { |options| options[:controller] }
end
controllers() click to toggle source
# File lib/releaf/content/configuration.rb, line 42
def controllers
  controller_names.map(&:constantize)
end
default_model() click to toggle source
# File lib/releaf/content/configuration.rb, line 38
def default_model
  models.first
end
model_names() click to toggle source
# File lib/releaf/content/configuration.rb, line 34
def model_names
  @model_names ||= resources.keys
end
models() click to toggle source
# File lib/releaf/content/configuration.rb, line 30
def models
  model_names.map(&:constantize)
end
resources=(value) click to toggle source
Calls superclass method
# File lib/releaf/content/configuration.rb, line 6
def resources=(value)
  verify_resources_config(value)
  super
end
routing() click to toggle source
# File lib/releaf/content/configuration.rb, line 50
def routing
  @routing ||= resources.map do | node_class_name, options |
    routing = options[:routing] || {}
    routing[:site]        ||= nil
    routing[:constraints] ||= nil
    [ node_class_name, routing ]
  end.to_h
end
verify_resources_config(resource_config) click to toggle source
# File lib/releaf/content/configuration.rb, line 11
def verify_resources_config(resource_config)
  # perform some basic config structure validation
  unless resource_config.is_a? Hash
    raise Releaf::Error, "Releaf.application.config.content.resources must be a Hash"
  end

  resource_config.each do | key, values |
    unless key.is_a? String
      raise Releaf::Error, "Releaf.application.config.content.resources must have string keys"
    end
    unless values.is_a? Hash
      raise Releaf::Error, "#{key} in Releaf.application.config.content.resources must have a hash value"
    end
    unless values[:controller].is_a? String
      raise Releaf::Error, "#{key} in Releaf.application.config.content.resources must have controller class specified as a string"
    end
  end
end