module Sinatra::Rabbit::Features

Public Class Methods

included(base) click to toggle source
# File lib/sinatra/rabbit/features.rb, line 90
def self.included(base)
  base.register(Features) if base.respond_to? :register
end

Public Instance Methods

feature(name, opts={}, &block) click to toggle source
# File lib/sinatra/rabbit/features.rb, line 79
def feature(name, opts={}, &block)
  feature = @features.find { |f| f.name == name }
  return feature unless block_given?
  if feature
    feature.instance_eval(&block)
  else
    @features << Feature.new(name, opts, &block) if block_given?
  end
  @features.find { |f| f.name == name }
end
features(&block) click to toggle source
# File lib/sinatra/rabbit/features.rb, line 72
def features(&block)
  return @features || [] unless block_given?
  @features ||= []
  instance_eval(&block)
  @features
end