Module: Sinatra::Rabbit::Features

Defined in:
lib/sinatra/rabbit/features.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



90
91
92
# File 'lib/sinatra/rabbit/features.rb', line 90

def self.included(base)
  base.register(Features) if base.respond_to? :register
end

Instance Method Details

#feature(name, opts = {}, &block) ⇒ Object



79
80
81
82
83
84
85
86
87
88
# 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) ⇒ Object



72
73
74
75
76
77
# File 'lib/sinatra/rabbit/features.rb', line 72

def features(&block)
  return @features || [] unless block_given?
  @features ||= []
  instance_eval(&block)
  @features
end