class Spectifly::Sequel::FieldForMigration
Attributes
field_name[RW]
field_type[RW]
model[RW]
options[RW]
Public Class Methods
new(field, model, entity_references)
click to toggle source
# File lib/spectifly/sequel/field_for_migration.rb, line 6 def initialize(field, model, entity_references) @field = field @field_name = field.name @field_type = field.type @model = model @options = retrieve_options(field) end
Public Instance Methods
multiple_value_simple_type?()
click to toggle source
# File lib/spectifly/sequel/field_for_migration.rb, line 40 def multiple_value_simple_type? @model_for_field.nil? && @field.multiple? end
render()
click to toggle source
# File lib/spectifly/sequel/field_for_migration.rb, line 21 def render template = if single_value_simple_type? 'single_value_simple_type_field' elsif multiple_value_simple_type? 'multiple_value_simple_type_field' end return if template.nil? path = File.expand_path(File.join(*File.dirname(__FILE__), 'erb', 'field', "#{template}.erb")) content = File.read(path) t = ERB.new(content, nil, '-') t.filename = path t.result(binding) end
retrieve_options(field)
click to toggle source
# File lib/spectifly/sequel/field_for_migration.rb, line 14 def retrieve_options(field) options = [] options << ':null => false' if field.required? options << ':unique => true' if field.unique? options end
single_value_simple_type?()
click to toggle source
# File lib/spectifly/sequel/field_for_migration.rb, line 36 def single_value_simple_type? @model_for_field.nil? && !@field.multiple? end