Class: Meteor::AttributeMap
- Inherits:
-
Object
- Object
- Meteor::AttributeMap
- Defined in:
- lib/meteor.rb
Overview
属性マップクラス
Instance Attribute Summary collapse
-
#map ⇒ Object
Returns the value of attribute map.
-
#recordable ⇒ Object
Returns the value of attribute recordable.
Instance Method Summary collapse
-
#[](name) ⇒ String
属性名で属性値を取得する.
-
#changed(name) ⇒ TrueClass, FalseClass
属性名で属性の変更状況を取得する.
-
#delete(name) ⇒ Object
属性名に対応した属性を削除する.
-
#fetch(name) ⇒ String
属性名で属性値を取得する.
-
#initialize(*args) ⇒ AttributeMap
constructor
A new instance of AttributeMap.
-
#names ⇒ Array
属性名配列を取得する.
-
#removed(name) ⇒ TrueClass, FalseClass
属性名で属性の削除状況を取得する.
-
#store(name, value) ⇒ Object
属性名と属性値を対としてセットする.
Constructor Details
#initialize(*args) ⇒ AttributeMap
Returns a new instance of AttributeMap.
396 397 398 399 400 401 402 403 404 405 |
# File 'lib/meteor.rb', line 396 def initialize(*args) case args.length when ZERO initialize_0 when ONE initialize_1(args[0]) else raise ArgumentError end end |
Instance Attribute Details
#map ⇒ Object
Returns the value of attribute map.
521 522 523 |
# File 'lib/meteor.rb', line 521 def map @map end |
#recordable ⇒ Object
Returns the value of attribute recordable.
522 523 524 |
# File 'lib/meteor.rb', line 522 def recordable @recordable end |
Instance Method Details
#[](name) ⇒ String
属性名で属性値を取得する
530 531 532 |
# File 'lib/meteor.rb', line 530 def [](name,value) store(name,value) end |
#changed(name) ⇒ TrueClass, FalseClass
属性名で属性の変更状況を取得する
504 505 506 507 508 |
# File 'lib/meteor.rb', line 504 def changed(name) if @map[name] then @map[name].changed end end |
#delete(name) ⇒ Object
属性名に対応した属性を削除する
492 493 494 495 496 497 |
# File 'lib/meteor.rb', line 492 def delete(name) if @recordable && @map[name] then @map[name].removed = true @map[name].changed = false end end |
#fetch(name) ⇒ String
属性名で属性値を取得する
481 482 483 484 485 |
# File 'lib/meteor.rb', line 481 def fetch(name) if @map[name] && !@map[name].removed then @map[name].value end end |
#names ⇒ Array
属性名配列を取得する
467 468 469 470 471 472 473 |
# File 'lib/meteor.rb', line 467 def names if RUBY_VERSION < RUBY_VERSION_1_9_0 @names else @map.keys end end |
#removed(name) ⇒ TrueClass, FalseClass
属性名で属性の削除状況を取得する
515 516 517 518 519 |
# File 'lib/meteor.rb', line 515 def removed(name) if @map[name] then @map[name].removed end end |
#store(name, value) ⇒ Object
属性名と属性値を対としてセットする
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'lib/meteor.rb', line 438 def store(name,value) if !@map[name] then attr = Attribute.new attr.name = name attr.value = value if @recordable then attr.changed = true attr.removed = false end @map[name] = attr if RUBY_VERSION < RUBY_VERSION_1_9_0 @names << name end else attr = @map[name] if @recordable && attr.value != value then attr.changed = true attr.removed = false end attr.value = value end end |