Class: Spider::Model::Storage::Db::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/spiderfw/model/storage/db/db_schema.rb

Direct Known Subclasses

FieldExpression

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table, name, type, attributes = {}) ⇒ Field

Returns a new instance of Field.



203
204
205
206
207
208
209
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 203

def initialize(table, name, type, attributes={})
    @table = table
    @name = name.to_s
    @type = type
    @attributes = attributes
    @table.add_field(self)
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



201
202
203
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 201

def attributes
  @attributes
end

#nameObject

Returns the value of attribute name.



200
201
202
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 200

def name
  @name
end

#tableObject (readonly)

Returns the value of attribute table.



199
200
201
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 199

def table
  @table
end

#typeObject

Returns the value of attribute type.



200
201
202
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 200

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



230
231
232
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 230

def ==(other)
    @table == other.table && @name == other.name
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


235
236
237
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 235

def eql?(other)
    self == other
end

#hashObject



239
240
241
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 239

def hash
    to_s.hash
end

#inspectObject



226
227
228
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 226

def inspect
    "#<#{self.class.name}:#{self.object_id} @name=\"#{@name}\", @table=#<Spider::Model::Storage::Db::Table:#{@table.object_id} #{@table.name}> >"
end

#primary_keyObject Also known as: primary_key?



212
213
214
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 212

def primary_key
    @attributes[:primary_key]
end

#primary_key=(val) ⇒ Object



217
218
219
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 217

def primary_key=(val)
    @attributes[:primary_key] = true
end

#to_sObject



222
223
224
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 222

def to_s
    "#{@table.name}.#{@name}"
end