Class: Meteor::AttributeMap
- Inherits:
-
Object
- Object
- Meteor::AttributeMap
- Defined in:
- lib/meteor.rb
Overview
Attribute Map Class (属性マップクラス)
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
get attribute value using attribute name (属性名で属性値を取得する).
-
#[]=(name, value) ⇒ Object
set a couple of attribute name and attribute value (属性名と属性値を対としてセットする).
-
#changed(name) ⇒ true, false
get update flag of attribute using attribute name (属性名で属性の変更フラグを取得する).
-
#delete(name) ⇒ Object
delete attribute using attribute name (属性名に対応した属性を削除する).
-
#fetch(name) ⇒ String
get attribute value using attribute name (属性名で属性値を取得する).
-
#initialize(*args) ⇒ AttributeMap
constructor
initializer (イニシャライザ).
-
#names ⇒ Array
get attribute name array (属性名配列を取得する).
-
#removed(name) ⇒ true, false
get delete flag of attribute using attribute name (属性名で属性の削除状況を取得する).
-
#store(name, value) ⇒ Object
set a couple of attribute name and attribute value (属性名と属性値を対としてセットする).
Constructor Details
#initialize ⇒ AttributeMap #initialize(attr_map) ⇒ AttributeMap
initializer (イニシャライザ)
611 612 613 614 615 616 617 618 619 620 |
# File 'lib/meteor.rb', line 611 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.
720 721 722 |
# File 'lib/meteor.rb', line 720 def map @map end |
#recordable ⇒ Object
Returns the value of attribute recordable.
721 722 723 |
# File 'lib/meteor.rb', line 721 def recordable @recordable end |
Instance Method Details
#[](name) ⇒ String
get attribute value using attribute name (属性名で属性値を取得する)
739 740 741 |
# File 'lib/meteor.rb', line 739 def [](name) fetch(name) end |
#[]=(name, value) ⇒ Object
set a couple of attribute name and attribute value (属性名と属性値を対としてセットする)
729 730 731 |
# File 'lib/meteor.rb', line 729 def []=(name, value) store(name, value) end |
#changed(name) ⇒ true, false
get update flag of attribute using attribute name (属性名で属性の変更フラグを取得する)
704 705 706 707 708 |
# File 'lib/meteor.rb', line 704 def changed(name) if @map[name] @map[name].changed end end |
#delete(name) ⇒ Object
delete attribute using attribute name (属性名に対応した属性を削除する)
693 694 695 696 697 698 |
# File 'lib/meteor.rb', line 693 def delete(name) if @recordable && @map[name] @map[name].removed = true @map[name].changed = false end end |
#fetch(name) ⇒ String
get attribute value using attribute name (属性名で属性値を取得する)
683 684 685 686 687 |
# File 'lib/meteor.rb', line 683 def fetch(name) if @map[name] && !@map[name].removed @map[name].value end end |
#names ⇒ Array
get attribute name array (属性名配列を取得する)
674 675 676 |
# File 'lib/meteor.rb', line 674 def names @map.keys end |
#removed(name) ⇒ true, false
get delete flag of attribute using attribute name (属性名で属性の削除状況を取得する)
714 715 716 717 718 |
# File 'lib/meteor.rb', line 714 def removed(name) if @map[name] @map[name].removed end end |
#store(name, value) ⇒ Object
set a couple of attribute name and attribute value (属性名と属性値を対としてセットする)
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
# File 'lib/meteor.rb', line 649 def store(name, value) if !@map[name] attr = Attribute.new attr.name = name attr.value = value if @recordable attr.changed = true attr.removed = false end @map[name] = attr else attr = @map[name] if @recordable && attr.value != value attr.changed = true attr.removed = false end attr.value = value end end |