Class: OpenStruct
- Inherits:
-
Object
- Object
- OpenStruct
- Defined in:
- lib/everythingrb/core/ostruct.rb
Instance Method Summary collapse
-
#blank? ⇒ Boolean
Checks if the OpenStruct has no attributes.
-
#filter_map(&block) ⇒ Enumerator, Array
Maps over OpenStruct entries and returns an array without nil values.
-
#join_map(join_with = "") {|Object| ... } ⇒ String
Combines filter_map and join operations.
-
#map ⇒ Enumerator, Array
Maps over OpenStruct entries and returns an array.
-
#present? ⇒ Boolean
Checks if the OpenStruct has any attributes.
- #to_ostruct ⇒ self
Instance Method Details
#blank? ⇒ Boolean
Checks if the OpenStruct has no attributes
10 11 12 |
# File 'lib/everythingrb/core/ostruct.rb', line 10 def blank? @table.blank? end |
#filter_map(&block) ⇒ Enumerator, Array
Maps over OpenStruct entries and returns an array without nil values
40 41 42 43 44 |
# File 'lib/everythingrb/core/ostruct.rb', line 40 def filter_map(&block) return enum_for(:filter_map) unless block map(&block).compact end |
#join_map(join_with = "") {|Object| ... } ⇒ String
Combines filter_map and join operations
65 66 67 68 69 |
# File 'lib/everythingrb/core/ostruct.rb', line 65 def join_map(join_with = "", &block) block = ->(kv_pair) { kv_pair.compact } if block.nil? filter_map(&block).join(join_with) end |
#map ⇒ Enumerator, Array
Maps over OpenStruct entries and returns an array
31 32 33 |
# File 'lib/everythingrb/core/ostruct.rb', line 31 def map(&) @table.map(&) end |
#present? ⇒ Boolean
Checks if the OpenStruct has any attributes
19 20 21 |
# File 'lib/everythingrb/core/ostruct.rb', line 19 def present? @table.present? end |
#to_ostruct ⇒ self
74 75 76 |
# File 'lib/everythingrb/core/ostruct.rb', line 74 def to_ostruct self end |