Class: Femto::Model::ModelCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/femto/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeModelCreator

Returns a new instance of ModelCreator.



104
105
106
107
108
109
# File 'lib/femto/model.rb', line 104

def initialize
  @fields = []
  @defaults = {}
  @types = {}
  @custom_methods = {}
end

Instance Attribute Details

#class_optsObject

Returns the value of attribute class_opts.



100
101
102
# File 'lib/femto/model.rb', line 100

def class_opts
  @class_opts
end

#custom_methodsObject

Returns the value of attribute custom_methods.



101
102
103
# File 'lib/femto/model.rb', line 101

def custom_methods
  @custom_methods
end

#defaultsObject

Returns the value of attribute defaults.



98
99
100
# File 'lib/femto/model.rb', line 98

def defaults
  @defaults
end

#fieldsObject

Returns the value of attribute fields.



97
98
99
# File 'lib/femto/model.rb', line 97

def fields
  @fields
end

#storage_nameObject

Returns the value of attribute storage_name.



102
103
104
# File 'lib/femto/model.rb', line 102

def storage_name
  @storage_name
end

#typesObject

Returns the value of attribute types.



99
100
101
# File 'lib/femto/model.rb', line 99

def types
  @types
end

Instance Method Details

#class_options(&block) ⇒ Object



119
120
121
# File 'lib/femto/model.rb', line 119

def class_options(&block)
  @class_opts = block
end

#field(name, options = {}) ⇒ Object



111
112
113
114
115
116
117
# File 'lib/femto/model.rb', line 111

def field(name, options={})
  return unless name
  fields << name
  if options[:default]
    defaults[name]
  end
end

#set_method(name, &block) ⇒ Object



123
124
125
# File 'lib/femto/model.rb', line 123

def set_method(name, &block)
  custom_methods[name] = block
end

#storage(name) ⇒ Object



127
128
129
# File 'lib/femto/model.rb', line 127

def storage(name)
  @storage_name = name
end