Class: Meteor::AttributeMap
- Inherits:
-
Object
- Object
- Meteor::AttributeMap
- Defined in:
- lib/meteor.rb,
lib/meteor.rb
Overview
Attribute Map Class (属性マップクラス)
Instance Attribute Summary (collapse)
-
- (Object) map
Returns the value of attribute map.
-
- (Object) recordable
Returns the value of attribute recordable.
Instance Method Summary (collapse)
-
- (String) [](name)
get attribute value using attribute name (属性名で属性値を取得する).
-
- (Object) []=(name, value)
set a couple of attribute name and attribute value (属性名と属性値を対としてセットする).
-
- (true, false) changed(name)
get update flag of attribute using attribute name (属性名で属性の変更フラグを取得する).
-
- (Object) delete(name)
delete attribute using attribute name (属性名に対応した属性を削除する).
-
- (String) fetch(name)
get attribute value using attribute name (属性名で属性値を取得する).
-
- (AttributeMap) initialize(*args)
constructor
initializer (イニシャライザ).
-
- (Object) initialize_0
initializer (イニシャライザ).
-
- (Object) initialize_1(attr_map)
initializer (イニシャライザ).
-
- (Array) names
get attribute name array (属性名配列を取得する).
-
- (true, false) removed(name)
get delete flag of attribute using attribute name (属性名で属性の削除状況を取得する).
-
- (Object) store(name, value)
set a couple of attribute name and attribute value (属性名と属性値を対としてセットする).
Constructor Details
- (AttributeMap) initialize - (AttributeMap) initialize(attr_map)
initializer (イニシャライザ)
477 478 479 480 481 482 483 484 485 486 |
# File 'lib/meteor.rb', line 477 def initialize(*args) case args.length when ZERO initialize_0 when ONE initialize_1(args[0]) else raise ArgumentError end end |
Instance Attribute Details
- (Object) map
Returns the value of attribute map
586 587 588 |
# File 'lib/meteor.rb', line 586 def map @map end |
- (Object) recordable
Returns the value of attribute recordable
587 588 589 |
# File 'lib/meteor.rb', line 587 def recordable @recordable end |
Instance Method Details
- (String) [](name)
get attribute value using attribute name (属性名で属性値を取得する)
605 606 607 |
# File 'lib/meteor.rb', line 605 def [](name) fetch(name) end |
- (Object) []=(name, value)
set a couple of attribute name and attribute value (属性名と属性値を対としてセットする)
595 596 597 |
# File 'lib/meteor.rb', line 595 def []=(name, value) store(name, value) end |
- (true, false) changed(name)
get update flag of attribute using attribute name (属性名で属性の変更フラグを取得する)
570 571 572 573 574 |
# File 'lib/meteor.rb', line 570 def changed(name) if @map[name] then @map[name].changed end end |
- (Object) delete(name)
delete attribute using attribute name (属性名に対応した属性を削除する)
559 560 561 562 563 564 |
# File 'lib/meteor.rb', line 559 def delete(name) if @recordable && @map[name] then @map[name].removed = true @map[name].changed = false end end |
- (String) fetch(name)
get attribute value using attribute name (属性名で属性値を取得する)
549 550 551 552 553 |
# File 'lib/meteor.rb', line 549 def fetch(name) if @map[name] && !@map[name].removed then @map[name].value end end |
- (Object) initialize_0
initializer (イニシャライザ)
492 493 494 495 496 |
# File 'lib/meteor.rb', line 492 def initialize_0 @map = Hash.new @names = Array.new @recordable = false end |
- (Object) initialize_1(attr_map)
initializer (イニシャライザ)
501 502 503 504 505 506 |
# File 'lib/meteor.rb', line 501 def initialize_1(attr_map) #@map = Marshal.load(Marshal.dump(attr_map.map)) @map = attr_map.map.dup @names = Array.new(attr_map.names) @recordable = attr_map.recordable end |
- (Array) names
get attribute name array (属性名配列を取得する)
537 538 539 |
# File 'lib/meteor.rb', line 537 def names @names end |
- (true, false) removed(name)
get delete flag of attribute using attribute name (属性名で属性の削除状況を取得する)
580 581 582 583 584 |
# File 'lib/meteor.rb', line 580 def removed(name) if @map[name] then @map[name].removed end end |
- (Object) store(name, value)
set a couple of attribute name and attribute value (属性名と属性値を対としてセットする)
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
# File 'lib/meteor.rb', line 512 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 @names << name else attr = @map[name] if @recordable && attr.value != value then attr.changed = true attr.removed = false end attr.value = value end end |