Class: Komagire::KeyList
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Komagire::KeyList
- Defined in:
- lib/komagire/key_list.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Converter
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#content_class_name ⇒ Object
readonly
Returns the value of attribute content_class_name.
Instance Method Summary collapse
-
#cskeys ⇒ String
comma separated keys.
- #freeze ⇒ Object
-
#initialize(content_class_name, attribute, cskeys, options = {}) ⇒ KeyList
constructor
A new instance of KeyList.
Constructor Details
#initialize(content_class_name, attribute, cskeys, options = {}) ⇒ KeyList
Returns a new instance of KeyList.
18 19 20 21 22 23 24 25 |
# File 'lib/komagire/key_list.rb', line 18 def initialize(content_class_name, attribute, cskeys, = {}) @content_class_name = content_class_name @attribute = attribute @delimiter = [:delimiter] || Komagire::DEFAULT_DELIMITER @sort = [:sort] || false @cskeys = _convert(cskeys) super(_find_by_cskeys) end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
11 12 13 |
# File 'lib/komagire/key_list.rb', line 11 def attribute @attribute end |
#content_class_name ⇒ Object (readonly)
Returns the value of attribute content_class_name.
11 12 13 |
# File 'lib/komagire/key_list.rb', line 11 def content_class_name @content_class_name end |
Instance Method Details
#cskeys ⇒ String
comma separated keys
30 31 32 33 |
# File 'lib/komagire/key_list.rb', line 30 def cskeys key_values = compact.map(&@attribute).uniq.tap {|values| values.sort! if @sort } ([''] + key_values + ['']).join(@delimiter) end |
#freeze ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/komagire/key_list.rb', line 35 def freeze case __getobj__ when ActiveRecord::Relation # avoid ActiveRecord::Relation is frozen else super end end |