Class: Extlib::SimpleSet
- Defined in:
- lib/gems/extlib-0.9.9/lib/extlib/simple_set.rb
Overview
Simple set implementation on top of Hash with merging support.
In particular this is used to store a set of callable actions of controller.
Constant Summary
Constants included from ActiveSupport::CoreExtensions::Hash::Conversions
ActiveSupport::CoreExtensions::Hash::Conversions::XML_FORMATTING, ActiveSupport::CoreExtensions::Hash::Conversions::XML_PARSING, ActiveSupport::CoreExtensions::Hash::Conversions::XML_TYPE_NAMES
Instance Method Summary collapse
-
#<<(value) ⇒ SimpleSet
Add a value to the set, and return it.
-
#initialize(arr = []) ⇒ Array
constructor
Create a new SimpleSet containing the unique members of arr.
-
#inspect ⇒ String
Get a human readable version of the set.
-
#merge(arr) ⇒ SimpleSet
Merge arr with receiver, producing the union of receiver & arr.
Methods inherited from Hash
#-, #add_html_class!, #environmentize_keys!, #except, from_xml, #join, #normalize_param, #only, #protect_keys!, #to_json, #to_mash, #to_params, #to_xml_attributes, #unprotect_keys!
Methods included from ActiveSupport::CoreExtensions::Hash::Except
Methods included from ActiveSupport::CoreExtensions::Hash::Slice
Methods included from ActiveSupport::CoreExtensions::Hash::Diff
Methods included from ActiveSupport::CoreExtensions::Hash::Conversions
Methods included from ActiveSupport::CoreExtensions::Hash::ReverseMerge
#reverse_merge, #reverse_merge!
Methods included from ActiveSupport::CoreExtensions::Hash::DeepMerge
Methods included from ActiveSupport::CoreExtensions::Hash::IndifferentAccess
Methods included from ActiveSupport::CoreExtensions::Hash::Keys
#assert_valid_keys, #stringify_keys, #stringify_keys!, #symbolize_keys, #symbolize_keys!
Constructor Details
Instance Method Details
#<<(value) ⇒ SimpleSet
Add a value to the set, and return it
29 30 31 32 |
# File 'lib/gems/extlib-0.9.9/lib/extlib/simple_set.rb', line 29 def <<(value) self[value] = true self end |
#inspect ⇒ String
58 59 60 |
# File 'lib/gems/extlib-0.9.9/lib/extlib/simple_set.rb', line 58 def inspect "#<SimpleSet: {#{keys.map {|x| x.inspect}.join(", ")}}>" end |
#merge(arr) ⇒ SimpleSet
45 46 47 |
# File 'lib/gems/extlib-0.9.9/lib/extlib/simple_set.rb', line 45 def merge(arr) super(arr.inject({}) {|s,x| s[x] = true; s }) end |