Class: Spider::Model::Storage::Db::Field
- Defined in:
- lib/spiderfw/model/storage/db/db_schema.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#name ⇒ Object
Returns the value of attribute name.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(table, name, type, attributes = {}) ⇒ Field
constructor
A new instance of Field.
- #inspect ⇒ Object
- #primary_key ⇒ Object (also: #primary_key?)
- #primary_key=(val) ⇒ Object
- #to_s ⇒ Object
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
#attributes ⇒ Object
Returns the value of attribute attributes.
201 202 203 |
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 201 def attributes @attributes end |
#name ⇒ Object
Returns the value of attribute name.
200 201 202 |
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 200 def name @name end |
#table ⇒ Object (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 |
#type ⇒ Object
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
235 236 237 |
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 235 def eql?(other) self == other end |
#hash ⇒ Object
239 240 241 |
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 239 def hash to_s.hash end |
#inspect ⇒ Object
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_key ⇒ Object 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_s ⇒ Object
222 223 224 |
# File 'lib/spiderfw/model/storage/db/db_schema.rb', line 222 def to_s "#{@table.name}.#{@name}" end |