class ModelMaker::EntityBuilder

Attributes

entity[R]

Public Class Methods

new(entity_name, &configuration) click to toggle source
# File src/lib/modelmaker.rb, line 55
def initialize(entity_name, &configuration)
    @entity = Entity.new(entity_name)
    instance_eval(&configuration)
end

Public Instance Methods

add_dependency(cls) click to toggle source
# File src/lib/modelmaker.rb, line 102
def add_dependency(cls)
    @entity.add_dependency(cls)
end
add_property(property) click to toggle source
# File src/lib/modelmaker.rb, line 98
def add_property(property)
    @entity.add_property(property)
end
array(*args) click to toggle source
# File src/lib/modelmaker.rb, line 85
def array(*args)
    add_property(ArrayProperty.new(*args))
end
conforms_to(protocol) click to toggle source
# File src/lib/modelmaker.rb, line 64
def conforms_to(protocol)
    @entity.protocols << protocol
end
date(propname) click to toggle source
# File src/lib/modelmaker.rb, line 89
def date(propname)
    add_property(DateProperty.new(propname))
end
id(propname, cls) click to toggle source
# File src/lib/modelmaker.rb, line 93
def id(propname, cls)
    add_property(IdProperty.new(propname, cls))
    add_dependency(cls)
end
inherits(superclass) click to toggle source
# File src/lib/modelmaker.rb, line 60
def inherits(superclass)
    @entity.superclass = superclass
end
int(propname) click to toggle source
# File src/lib/modelmaker.rb, line 73
def int(propname)
    add_property(IntegerProperty.new(propname))
end
set(propname) click to toggle source
# File src/lib/modelmaker.rb, line 77
def set(propname)
    add_property(SetProperty.new(propname))
end
string(propname) click to toggle source

 There was a way to do that better… “define_all” or something

# File src/lib/modelmaker.rb, line 69
def string(propname)
    add_property(StringProperty.new(propname))
end
url(propname) click to toggle source
# File src/lib/modelmaker.rb, line 81
def url(propname)
    add_property(UrlProperty.new(propname))
end