Class: Tipsy::Site

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::Configurable
Defined in:
lib/tipsy/site.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSite

Returns a new instance of Site.



106
107
# File 'lib/tipsy/site.rb', line 106

def initialize      
end

Class Method Details

.configure!Object



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/tipsy/site.rb', line 68

def self.configure!
  @_callbacks = { :before => [], :after => [] }
  local_config = File.join(Tipsy.root, 'config.rb')
  if File.exists?(local_config)
    bind = binding
    self.class_exec do
      File.open(local_config).each do |line|
        next if line.to_s[0] == "#" || line.to_s.strip.blank?
        eval("config."+ line.to_s, bind, local_config)
      end
    end
  end
end

Instance Method Details

#callbackObject

Callback support



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/tipsy/site.rb', line 85

[:compile].each do |callback|
  class_eval <<-METHOD, __FILE__, __LINE__ + 1
    def self.before_#{callback}(&block)
      if block_given?
        @_callbacks[:before] << block
      else
        @_callbacks[:before].each(&:call)
      end
    end

    def self.after_#{callback}(&block)
      if block_given?
        @_callbacks[:after] << block
      else
        @_callbacks[:after].each(&:call)
      end
    end
  METHOD
end