Sha256: e0371d2fe7189e711352db895538057270c7be4968827c7428a4333c19b97ce6
Contents?: true
Size: 957 Bytes
Versions: 4
Compression:
Stored size: 957 Bytes
Contents
module Siringa # Load definitions from files def self.load_definitions Dir[Rails.root.join("#{self.configuration.definitions_path}/**/*.rb")].each { |f| require f } end # Load a definition and run its code # # @param [Symbol] name of the definition def self.load_definition(name) if exists_definition?(name) @definitions[name].call else raise ArgumentError, "Definition #{name.to_s} does not exist.", caller end end # Add a definition # # @param [Symbol] name of the definition # @param [Proc] code to run def self.add_definition(name, &block) if !exists_definition?(name) @definitions[name] = Proc.new(&block) else raise ArgumentError, "Definition #{name.to_s} already exists." end end # Check if a definition already exists # # @param [Symbol] name of the definition # @return [Boolean] def self.exists_definition?(name) !@definitions[name].nil? end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
siringa-0.0.5 | lib/siringa/definitions.rb |
siringa-0.0.4 | lib/siringa/definitions.rb |
siringa-0.0.3 | lib/siringa/definitions.rb |
siringa-0.0.1 | lib/siringa/definitions.rb |