Class: Ccp::Fixtures::Writers::Base
- Inherits:
-
Object
- Object
- Ccp::Fixtures::Writers::Base
- Defined in:
- lib/ccp/fixtures/writers.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(hash, path) ⇒ Base
constructor
A new instance of Base.
- #serialize(data) ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize(hash, path) ⇒ Base
Returns a new instance of Base.
9 10 11 12 |
# File 'lib/ccp/fixtures/writers.rb', line 9 def initialize(hash, path) @hash = hash.must(Hash) @path = path.must(Pathname) end |
Class Method Details
.[]=(path, hash) ⇒ Object
5 6 7 |
# File 'lib/ccp/fixtures/writers.rb', line 5 def self.[]= (path, hash) new(hash,path).execute end |
Instance Method Details
#execute ⇒ Object
23 24 25 |
# File 'lib/ccp/fixtures/writers.rb', line 23 def execute write(serialize(@hash)) end |
#serialize(data) ⇒ Object
14 15 16 |
# File 'lib/ccp/fixtures/writers.rb', line 14 def serialize(data) data end |
#write(data) ⇒ Object
18 19 20 21 |
# File 'lib/ccp/fixtures/writers.rb', line 18 def write(data) @path.parent.mkpath @path.open("w+"){|f| f.print data} end |