Module: Chozo::CleanRoom::ClassMethods
- Defined in:
- lib/chozo/clean_room.rb
Instance Method Summary collapse
- #clean_room ⇒ CleanRoomBase
- #from_file(filepath) ⇒ Cookbook::Metadata
- #from_json_file(filepath) ⇒ Object
- #from_ruby_file(filepath) ⇒ Object
- #noisy_clean_room(value = nil) ⇒ Object
- #set_clean_room(klass) ⇒ Object
Instance Method Details
#clean_room ⇒ CleanRoomBase
8 9 10 |
# File 'lib/chozo/clean_room.rb', line 8 def clean_room @clean_room ||= CleanRoom.fabricate(self) end |
#from_file(filepath) ⇒ Cookbook::Metadata
15 16 17 18 19 20 21 22 23 |
# File 'lib/chozo/clean_room.rb', line 15 def from_file(filepath) filepath = filepath.to_s if File.extname(filepath) =~ /\.json/ from_json_file(filepath) else from_ruby_file(filepath) end end |
#from_json_file(filepath) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/chozo/clean_room.rb', line 25 def from_json_file(filepath) = JSON.parse(File.read(filepath)) obj = new obj.clean_eval do .each { |key, val| send(key.to_sym, val) } end obj end |
#from_ruby_file(filepath) ⇒ Object
35 36 37 38 39 |
# File 'lib/chozo/clean_room.rb', line 35 def from_ruby_file(filepath) obj = new obj.clean_eval(File.read(filepath), filepath, 1) obj end |
#noisy_clean_room(value = nil) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/chozo/clean_room.rb', line 45 def noisy_clean_room(value = nil) if value.nil? @noisy_clean_room else @noisy_clean_room = value end end |
#set_clean_room(klass) ⇒ Object
41 42 43 |
# File 'lib/chozo/clean_room.rb', line 41 def set_clean_room(klass) @clean_room = klass end |