Module: ReferenceBook
- Defined in:
- lib/reference_book.rb,
lib/reference_book.rb,
lib/reference_book/version.rb
Defined Under Namespace
Modules: Inflector, Library, Setup Classes: Book, BookDefinitionError, Error, LockedBookSpecError
Constant Summary collapse
- VERSION =
"0.0.3"
Class Attribute Summary collapse
-
.locked_book_spec ⇒ Object
readonly
Returns the value of attribute locked_book_spec.
Class Method Summary collapse
-
.define_book_structure(*book_keys) ⇒ Object
to lock the structure of Books, optional.
- .library ⇒ Object
-
.write_book(opts = {}) {|collector| ... } ⇒ Object
with block with 1 argument.
Class Attribute Details
.locked_book_spec ⇒ Object (readonly)
Returns the value of attribute locked_book_spec.
17 18 19 |
# File 'lib/reference_book.rb', line 17 def locked_book_spec @locked_book_spec end |
Class Method Details
.define_book_structure(*book_keys) ⇒ Object
to lock the structure of Books, optional
ReferenceBook.define_book_structure :attr_1, :attr_2, ‘attr_3’, …
24 25 26 |
# File 'lib/reference_book.rb', line 24 def define_book_structure(*book_keys) @locked_book_spec = Setup::LockedBookSpec.new(book_keys) end |
.library ⇒ Object
47 48 49 |
# File 'lib/reference_book.rb', line 47 def library ReferenceBook::Library end |
.write_book(opts = {}) {|collector| ... } ⇒ Object
with block with 1 argument
ReferenceBook.write_book(title: :sym_or_str) do |book|
book.some_prop = "foobar"
end
36 37 38 39 40 41 42 43 44 |
# File 'lib/reference_book.rb', line 36 def write_book(opts = {}, &block) collector = Setup::Collector.new yield collector writer = Setup::Writer.new(locked_book_spec) book = writer.create_book_with(opts[:title], opts[:library_key], collector) library.store(book) end |