Module: Frill

Included in:
ViewContextFrill
Defined in:
lib/frill/frill.rb,
lib/frill/rails.rb,
lib/frill/rspec.rb,
lib/frill/rspec.rb,
lib/frill/engine.rb

Defined Under Namespace

Modules: Auto, ClassMethods, RSpec Classes: CyclicDependency, DependencyGraph, Engine

Class Method Summary collapse

Class Method Details

.decorate(object, context, options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/frill/frill.rb', line 19

def self.decorate object, context, options={}
  frills = decorators

  if subset = options[:with]
    frills.select! {|d| subset.include? d}
  end

  frills.each do |f|
    object.extend f if f.frill? object, context
  end

  object
end

.decoratorsObject



9
10
11
12
# File 'lib/frill/frill.rb', line 9

def self.decorators
  @decorators ||= dependency_graph.to_a
  @decorators.dup
end

.dependency_graphObject



33
34
35
# File 'lib/frill/frill.rb', line 33

def self.dependency_graph
  @dependency_graph ||= DependencyGraph.new
end

.included(base) ⇒ Object



4
5
6
7
# File 'lib/frill/frill.rb', line 4

def self.included base
  self.dependency_graph.add base
  base.extend ClassMethods
end

.reset!Object



14
15
16
17
# File 'lib/frill/frill.rb', line 14

def self.reset!
  @decorators = nil
  @dependency_graph = nil
end