Module: PlainRecord::File

Included in:
Resource
Defined in:
lib/plain_record/file.rb

Overview

Extention to set to get field value from external file.

class Post
  include PlainRecord::Resource

  entry_in '*/post.md'

  virtual :name, in_filepath(1)
  virtuel :text, file { |p| "#{p.name}/text.#{I18n.locale}.md" }
end

Defined Under Namespace

Modules: Model

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#unsaved_filesObject

Cache of field content before save.



34
35
36
# File 'lib/plain_record/file.rb', line 34

def unsaved_files
  @unsaved_files
end

Instance Method Details

#field_filepath(field) ⇒ Object

Return file pathname for fiel field.



37
38
39
40
41
# File 'lib/plain_record/file.rb', line 37

def field_filepath(field)
  path = self.class.fields_files[field]
  path = path.call(self) if path.is_a? Proc
  PlainRecord.root(path)
end