Sha256: f2dd1aaa62c2b1aa0c1a30ae2b6726f5f9ccf262ce904f36a926a9ded4c8bed9
Contents?: true
Size: 1.34 KB
Versions: 47
Compression:
Stored size: 1.34 KB
Contents
# frozen_string_literal: true module Alchemy class Element < BaseRecord # Module concerning element definitions # module Definitions extend ActiveSupport::Concern module ClassMethods # Register a custom element definitions repository # # The default repository is Alchemy::ElementDefinition # def definitions_repository=(klass) @_definitions_repository = klass end # Returns the definitions from elements.yml file. # # Place a +elements.yml+ file inside your apps +config/alchemy+ folder to define # your own set of elements # def definitions definitions_repository.all end # Returns one element definition by given name. # def definition_by_name(name) definitions_repository.get(name) end private def definitions_repository @_definitions_repository ||= ElementDefinition end end # The definition of this element. # def definition if (definition = self.class.definition_by_name(name)) definition else log_warning "Could not find element definition for #{name}. " \ "Please check your elements.yml file!" {} end end end end end
Version data entries
47 entries across 47 versions & 1 rubygems