Module: Transit

Extended by:
Transit
Includes:
ActiveSupport::Configurable
Included in:
Transit
Defined in:
lib/transit.rb,
lib/transit/hooks.rb,
lib/transit/error.rb,
lib/transit/engine.rb,
lib/transit/version.rb,
lib/transit/delivery.rb,
lib/transit/extension.rb,
lib/transit/definition.rb,
lib/transit/deliverable.rb,
lib/transit/configuration.rb,
lib/transit/definitions/post.rb,
lib/transit/definitions/page.rb,
lib/transit/definitions/base.rb,
lib/transit/extensions/publishing.rb,
lib/transit/extensions/attachments.rb,
lib/transit/extensions/content_blocks.rb,
lib/generators/transit/setup_generator.rb

Overview

Setup default configuration options

Defined Under Namespace

Modules: Definition, Deliverable, Extension, Generators, Support Classes: Delivery, Engine

Constant Summary

VERSION =
"0.1.0"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.execute_hook(base, options, block) ⇒ Object

Executes a definition hook



39
40
41
42
43
44
45
# File 'lib/transit/hooks.rb', line 39

def self.execute_hook(base, options, block)
  if options[:yield]
    block.call(base)
  else
    base.instance_eval(&block)
  end
end

.on_definition(name, options = {}, &block) ⇒ Object

Add a hook to be called when a deliverable definition is applied to a class.

Parameters:

  • name (String, Symbol)

    The name of the definition to respond to

  • options (Hash) (defaults to: {})

    A hash of options to be passed to the block when called

  • &block (Proc)

    The block to call



28
29
30
31
32
33
34
# File 'lib/transit/hooks.rb', line 28

def self.on_definition(name, options = {}, &block)
  if base = @defined[name]
    execute_hook(base, options, block)
  else
    @definition_hooks[name] << [block, options]
  end
end

.run_definition_hooks(name, base = Object) ⇒ Object

Runs all definition hooks for a particular definition

Parameters:

  • name (String, Symbol)

    The name of the definition in which callbacks should be run

  • base (Object) (defaults to: Object)

    This class becomes the scope in which the block will be run.



52
53
54
55
56
57
# File 'lib/transit/hooks.rb', line 52

def self.run_definition_hooks(name, base = Object)
  @defined[name] = base
  @definition_hooks[name].each do |hook, options|
    execute_hook(base, options, hook)
  end
end

Instance Method Details

#configure {|config| ... } ⇒ Object

Configure options using a block

Yields:

  • (config)


26
27
28
# File 'lib/transit.rb', line 26

def configure
  yield config
end

#deliverablesObject

Stores a hash which identifies all registered deliverables within the app.



19
20
21
# File 'lib/transit.rb', line 19

def deliverables
  @deliverables ||= {}
end