Class: Alf::Types::Keys

Inherits:
Object
  • Object
show all
Includes:
Support::OrderedSet
Defined in:
lib/alf/types/keys.rb

Constant Summary collapse

EMPTY =
Keys.new([])

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Support::OrderedSet

#&, #-, #elements, #map, #|

Class Method Details

.[](*args) ⇒ Object


10
# File 'lib/alf/types/keys.rb', line 10

def self.[](*args); coerce(args); end

Instance Method Details

#if_empty(keys = nil, &bl) ⇒ Object


12
13
14
15
# File 'lib/alf/types/keys.rb', line 12

def if_empty(keys = nil, &bl)
  return self unless empty?
  Keys.coerce(keys || bl.call)
end

#project(attributes, allbut = false) ⇒ Object


17
18
19
# File 'lib/alf/types/keys.rb', line 17

def project(attributes, allbut = false)
  map{|k| k.project(attributes, allbut) }
end

#rename(renaming) ⇒ Object


21
22
23
24
# File 'lib/alf/types/keys.rb', line 21

def rename(renaming)
  renaming = Renaming.coerce(renaming)
  map{|k| renaming.rename_attr_list(k) }
end

#to_ruby_literalObject Also known as: to_s, inspect


26
27
28
# File 'lib/alf/types/keys.rb', line 26

def to_ruby_literal
  "Alf::Keys[" << reused_instance.map{|k| Support.to_ruby_literal(k.to_a) }.join(',') << "]"
end