Class: Houston::Extensions::Features

Inherits:
Object
  • Object
show all
Defined in:
lib/houston/boot/extensions/features.rb

Instance Method Summary collapse

Constructor Details

#initializeFeatures

Returns a new instance of Features.



9
10
11
# File 'lib/houston/boot/extensions/features.rb', line 9

def initialize
  @features = Concurrent::Hash.new
end

Instance Method Details

#[](slug) ⇒ Object



33
34
35
# File 'lib/houston/boot/extensions/features.rb', line 33

def [](slug)
  @features.fetch(slug)
end

#add(content, &path_block) ⇒ Object Also known as: <<



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/houston/boot/extensions/features.rb', line 13

def add(content, &path_block)
  if content.is_a?(Symbol)
    slug = content
    content = slug.to_s.titleize
  else
    slug = content.underscore.to_sym
  end
  Chain(AbilityBlock, AcceptsName, Feature.new(slug, content).tap do |feature|
    feature.instance_variable_set :@path_block, path_block
    feature.extend Houston::Extensions::HasForm
    @features[slug] = feature
  end)
end

#allObject Also known as: to_a



28
29
30
# File 'lib/houston/boot/extensions/features.rb', line 28

def all
  @features.keys
end