Class: Meteor::AttributeMap
- Inherits:
-
Object
- Object
- Meteor::AttributeMap
- Defined in:
- lib/meteor/attribute_map.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 (イニシャライザ)
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/meteor/attribute_map.rb', line 15 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.
125 126 127 |
# File 'lib/meteor/attribute_map.rb', line 125 def map @map end |
#recordable ⇒ Object
Returns the value of attribute recordable.
126 127 128 |
# File 'lib/meteor/attribute_map.rb', line 126 def recordable @recordable end |
Instance Method Details
#[](name) ⇒ String
get attribute value using attribute name (属性名で属性値を取得する)
144 145 146 |
# File 'lib/meteor/attribute_map.rb', line 144 def [](name) fetch(name) end |
#[]=(name, value) ⇒ Object
set a couple of attribute name and attribute value (属性名と属性値を対としてセットする)
134 135 136 |
# File 'lib/meteor/attribute_map.rb', line 134 def []=(name, value) store(name, value) end |
#changed(name) ⇒ true, false
get update flag of attribute using attribute name (属性名で属性の変更フラグを取得する)
109 110 111 112 113 |
# File 'lib/meteor/attribute_map.rb', line 109 def changed(name) if @map[name] @map[name].changed end end |
#delete(name) ⇒ Object
delete attribute using attribute name (属性名に対応した属性を削除する)
98 99 100 101 102 103 |
# File 'lib/meteor/attribute_map.rb', line 98 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 (属性名で属性値を取得する)
88 89 90 91 92 |
# File 'lib/meteor/attribute_map.rb', line 88 def fetch(name) if @map[name] && !@map[name].removed @map[name].value end end |
#names ⇒ Array
get attribute name array (属性名配列を取得する)
79 80 81 |
# File 'lib/meteor/attribute_map.rb', line 79 def names @map.keys end |
#removed(name) ⇒ true, false
get delete flag of attribute using attribute name (属性名で属性の削除状況を取得する)
119 120 121 122 123 |
# File 'lib/meteor/attribute_map.rb', line 119 def removed(name) if @map[name] @map[name].removed end end |
#store(name, value) ⇒ Object
set a couple of attribute name and attribute value (属性名と属性値を対としてセットする)
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/meteor/attribute_map.rb', line 53 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 |