class NoSE::EntityDSL
A helper class for DSL
creation to avoid messing with {Entity}
Public Class Methods
new(entity)
click to toggle source
# File lib/nose/model/entity.rb, line 100 def initialize(entity) @entity = entity end
Public Instance Methods
PrimaryKey(*names)
click to toggle source
Specify a list of field names for the primary key
# File lib/nose/model/entity.rb, line 107 def PrimaryKey(*names) # Unset the old keys and set new ones, # we dup because the fields are frozen @entity.fields.each_value do |field| next unless field.primary_key? field = field.dup field.primary_key = false @entity.fields[field.name] = field field.freeze end names.each do |name| field = @entity[name].dup field.primary_key = true @entity.fields[name] = field field.freeze end end
etc(size = 1)
click to toggle source
rubocop:enable MethodName
# File lib/nose/model/entity.rb, line 128 def etc(size = 1) @entity << Fields::HashField.new('**', size) end