Changeset 188

Show
Ignore:
Timestamp:
02/15/07 21:15:52 (2 years ago)
Author:
e.@brainspl.at
Message:

checking in some changes to fragment cache adding trait method to Object , make the merb server spit out the options only after they have been munged so the correct options show

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/merb/caching/fragment_cache.rb

    r187 r188  
    44      class << self 
    55        def cache 
    6           @__cache ||= determine_cache_store 
     6          @cache ||= determine_cache_store 
    77        end 
    88         
  • trunk/lib/merb/core_ext/merb_object.rb

    r169 r188  
     1Traits = Hash.new{|h,k| h[k] = {}} 
     2 
    13class Object 
     4  # traits thanks to Michael Fellinger m.fellinger@gmail.com 
     5  # Adds a method to Object to annotate your objects with certain traits. 
     6  # It's basically a simple Hash that takes the current object as key 
     7  # 
     8  # Example: 
     9  # 
     10  #   class Foo 
     11  #     trait :instance => false 
     12  # 
     13  #     def initialize 
     14  #       trait :instance => true 
     15  #     end 
     16  #   end 
     17  # 
     18  #   Foo.trait[:instance] 
     19  #   # false 
     20  # 
     21  #   foo = Foo.new 
     22  #   foo.trait[:instance] 
     23  #   # true 
     24 
     25  def trait hash = nil 
     26    if hash 
     27      Traits[self].merge! hash 
     28    else 
     29      Traits[self] 
     30    end 
     31  end 
     32 
     33  # builds a trait from all the ancestors, closer ancestors 
     34  # overwrite distant ancestors 
     35  # 
     36  # class Foo 
     37  #   trait :one => :eins 
     38  #   trait :first => :erstes 
     39  # end 
     40  # 
     41  # class Bar < Foo 
     42  #   trait :two => :zwei 
     43  # end 
     44  # 
     45  # class Foobar < Bar 
     46  #   trait :three => :drei 
     47  #   trait :first => :overwritten 
     48  # end 
     49  # 
     50  # Foobar.ancestral_trait 
     51  # {:three=>:drei, :two=>:zwei, :one=>:eins, :first=>:overwritten} 
     52 
     53  def ancestral_trait 
     54    ancs = (ancestors rescue self.class.ancestors) 
     55    ancs.reverse.inject({}){|s,v| s.merge(v.trait)}.merge(trait) 
     56  end 
     57   
    258  def returning(value) 
    359    yield(value) 
     
    561  end 
    662   
    7   def __meta() class << self; self end end 
    8   def meta_eval(&blk) __meta.instance_eval( &blk ) end 
     63  def meta_class() class << self; self end end 
     64  def meta_eval(&blk) meta_class.instance_eval( &blk ) end 
    965  def meta_def(name, &blk) meta_eval { define_method name, &blk } end 
    1066  def class_def name, &blk 
  • trunk/lib/merb/merb_server.rb

    r182 r188  
    116116       
    117117        @@merb_opts = options 
    118         unless options[:generate] || options[:console] || options[:only_drb] || options[:kill] 
     118      end 
     119       
     120      def initialize_merb 
     121        unless  @@merb_opts[:generate] ||  @@merb_opts[:console] ||  @@merb_opts[:only_drb] ||  @@merb_opts[:kill] 
    119122          puts %{Merb started with these options:} 
    120123          puts @@merb_opts.to_yaml; puts 
    121124        end 
    122       end 
    123        
    124       def initialize_merb 
    125125        require 'merb' 
    126126        require @@merb_opts[:merb_root] / 'dist/conf/router.rb'