Module: FileModel::ClassMethods

Defined in:
lib/file_model/file_model.rb

Instance Method Summary collapse

Instance Method Details

#box(name = nil) ⇒ Object



138
139
140
141
142
143
144
# File 'lib/file_model/file_model.rb', line 138

def box name = nil
  if name
    self.box_name = name
  else
    FileModel.box box_name
  end
end

#version(name, &block) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/file_model/file_model.rb', line 123

def version name, &block
  klass = Class.new FileModel::Version, &block
  versions[name] = klass

  iv_name = :"@#{name}"
  define_method name do
    unless version = instance_variable_get(iv_name)
      version = klass.new self, name
      instance_variable_set iv_name, version
    end
    version
  end
end