Module: PlainRecord::Type
- Included in:
- Model
- Defined in:
- lib/plain_record/type.rb
Overview
Extention to set field type and convert value to it.
class Post
include PlainRecord::Resource
entry_in '*/*/post.md'
field :title, type(String)
field :visits, type(Integer)
field :rating, type(Float)
field :created, type(Date)
field :updated, type(Time)
end
You can add support for your classes. Just set parse and stringify code to PlainRecord::Type
:
PlainRecord::Type.parsers[Car] = 'Car.parse(super)'
PlainRecord::Type.stringifies[Car] = 'v.to_s'
Class Attribute Summary collapse
-
.parsers ⇒ Object
Hash of class to string of parse code.
-
.stringifies ⇒ Object
Hash of class to string of stringify code.
Class Attribute Details
.parsers ⇒ Object
Hash of class to string of parse code.
65 66 67 |
# File 'lib/plain_record/type.rb', line 65 def parsers @parsers end |
.stringifies ⇒ Object
Hash of class to string of stringify code.
68 69 70 |
# File 'lib/plain_record/type.rb', line 68 def stringifies @stringifies end |