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) ⇒ true, false
属性名で属性の変更状況を取得する.
-
#delete(name) ⇒ Object
属性名に対応した属性を削除する.
-
#fetch(name) ⇒ String
属性名で属性値を取得する.
-
#initialize(*args) ⇒ AttributeMap
constructor
イニシャライザ.
-
#names ⇒ Array
属性名配列を取得する.
-
#removed(name) ⇒ true, false
属性名で属性の削除状況を取得する.
-
#store(name, value) ⇒ Object
属性名と属性値を対としてセットする.
Constructor Details
#initialize ⇒ AttributeMap #initialize(attr_map) ⇒ AttributeMap
イニシャライザ
453 454 455 456 457 458 459 460 461 462 |
# File 'lib/meteor.rb', line 453 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.
573 574 575 |
# File 'lib/meteor.rb', line 573 def map @map end |
#recordable ⇒ Object
Returns the value of attribute recordable.
574 575 576 |
# File 'lib/meteor.rb', line 574 def recordable @recordable end |
Instance Method Details
#[](name) ⇒ String
属性名で属性値を取得する
582 583 584 |
# File 'lib/meteor.rb', line 582 def [](name,value) store(name,value) end |
#changed(name) ⇒ true, false
属性名で属性の変更状況を取得する
557 558 559 560 561 |
# File 'lib/meteor.rb', line 557 def changed(name) if @map[name] then @map[name].changed end end |
#delete(name) ⇒ Object
属性名に対応した属性を削除する
546 547 548 549 550 551 |
# File 'lib/meteor.rb', line 546 def delete(name) if @recordable && @map[name] then @map[name].removed = true @map[name].changed = false end end |
#fetch(name) ⇒ String
属性名で属性値を取得する
536 537 538 539 540 |
# File 'lib/meteor.rb', line 536 def fetch(name) if @map[name] && !@map[name].removed then @map[name].value end end |
#names ⇒ Array
属性名配列を取得する
523 524 525 526 527 528 529 |
# File 'lib/meteor.rb', line 523 def names if RUBY_VERSION < RUBY_VERSION_1_9_0 @names else @map.keys end end |
#removed(name) ⇒ true, false
属性名で属性の削除状況を取得する
567 568 569 570 571 |
# File 'lib/meteor.rb', line 567 def removed(name) if @map[name] then @map[name].removed end end |
#store(name, value) ⇒ Object
属性名と属性値を対としてセットする
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
# File 'lib/meteor.rb', line 495 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 |