Module: Scorched

Defined in:
lib/scorched/error.rb,
lib/scorched/match.rb,
lib/scorched/static.rb,
lib/scorched/options.rb,
lib/scorched/request.rb,
lib/scorched/version.rb,
lib/scorched/response.rb,
lib/scorched/collection.rb,
lib/scorched/controller.rb,
lib/scorched/dynamic_delegate.rb

Defined Under Namespace

Modules: DynamicDelegate Classes: Collection, Controller, Error, Match, Options, Request, Response, Static

Constant Summary collapse

VERSION =
'1.0.0'
TemplateCache =
Tilt::Cache.new

Class Method Summary collapse

Class Method Details

.Collection(accessor_name, append_parent = false) ⇒ Object


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/scorched/collection.rb', line 41

def Collection(accessor_name, append_parent = false)
  m = Module.new
  m.class_eval <<-MOD
    class << self
      def included(klass)
        klass.extend(ClassMethods)
      end
    end

    module ClassMethods
      def #{accessor_name}
        @#{accessor_name} || begin
          parent = superclass.#{accessor_name} if superclass.respond_to?(:#{accessor_name}) && Scorched::Collection === superclass.#{accessor_name}
          @#{accessor_name} = Collection.new.parent!(parent)
          @#{accessor_name}.append_parent = #{append_parent.inspect}
          @#{accessor_name}
        end
      end
    end

    def #{accessor_name}(*args)
      self.class.#{accessor_name}(*args)
    end
  MOD
  m
end

.Options(accessor_name) ⇒ Object


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/scorched/options.rb', line 42

def Options(accessor_name)
  m = Module.new
  m.class_eval <<-MOD
    class << self
      def included(klass)
        klass.extend(ClassMethods)
      end
    end

    module ClassMethods
      def #{accessor_name}
        @#{accessor_name} || begin
          parent = superclass.#{accessor_name} if superclass.respond_to?(:#{accessor_name}) && Scorched::Options === superclass.#{accessor_name}
          @#{accessor_name} = Options.new.parent!(parent)
        end
      end
    end

    def #{accessor_name}(*args)
      self.class.#{accessor_name}(*args)
    end
  MOD
  m
end