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.



102
103
# File 'lib/tipsy/site.rb', line 102

def initialize      
end

Class Method Details

.configure!Object



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/tipsy/site.rb', line 64

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



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/tipsy/site.rb', line 81

[: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