Class: FakeFlorence::FeatureCache
- Inherits:
-
Object
- Object
- FakeFlorence::FeatureCache
- Defined in:
- lib/fake_florence/feature_cache.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #announce_all_now ⇒ Object
- #feature(id) ⇒ Object
- #features ⇒ Object
- #id_to_file(id) ⇒ Object
-
#initialize(path) ⇒ FeatureCache
constructor
A new instance of FeatureCache.
- #register_listener(&block) ⇒ Object
Constructor Details
#initialize(path) ⇒ FeatureCache
Returns a new instance of FeatureCache.
7 8 9 10 11 |
# File 'lib/fake_florence/feature_cache.rb', line 7 def initialize(path) @root = path.join('features') @root.mkpath @callbacks = [] end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
5 6 7 |
# File 'lib/fake_florence/feature_cache.rb', line 5 def root @root end |
Instance Method Details
#announce_all_now ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/fake_florence/feature_cache.rb', line 30 def announce_all_now names = [] Announcers.load(Config.announce).each do |announcer| names.push(announcer.name) if announcer.announce(noop: features) end { features: features.size, announcers: names } end |
#feature(id) ⇒ Object
17 18 19 |
# File 'lib/fake_florence/feature_cache.rb', line 17 def feature(id) Feature.read(id, id_to_file(id)) end |
#features ⇒ Object
13 14 15 |
# File 'lib/fake_florence/feature_cache.rb', line 13 def features Dir.glob(@root.join('*.yaml')).map(&method(:file_to_feature)) end |
#id_to_file(id) ⇒ Object
26 27 28 |
# File 'lib/fake_florence/feature_cache.rb', line 26 def id_to_file(id) @root.join("#{id}.yaml") end |
#register_listener(&block) ⇒ Object
21 22 23 24 |
# File 'lib/fake_florence/feature_cache.rb', line 21 def register_listener(&block) @callbacks.push(block) listen_for_changes unless @listener end |