Class: InOrder::Aux::Keys

Inherits:
Object
  • Object
show all
Defined in:
app/models/in_order/aux/keys.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_owner = nil, _scope = nil, owner: _owner, scope: _scope) ⇒ Keys

Returns a new instance of Keys.



7
8
9
10
11
# File 'app/models/in_order/aux/keys.rb', line 7

def initialize(_owner=nil, _scope=nil, owner: _owner, scope: _scope)
  self.owner = owner

  self.scope = scope
end

Instance Attribute Details

#ownerObject

Returns the value of attribute owner.



5
6
7
# File 'app/models/in_order/aux/keys.rb', line 5

def owner
  @owner
end

#scopeObject

Returns the value of attribute scope.



5
6
7
# File 'app/models/in_order/aux/keys.rb', line 5

def scope
  @scope
end

Instance Method Details

#==(other) ⇒ Object



46
47
48
# File 'app/models/in_order/aux/keys.rb', line 46

def ==(other)
  to_a == other.to_a
end

#call(**extras) ⇒ Object



13
14
15
# File 'app/models/in_order/aux/keys.rb', line 13

def call(**extras)
  to_params.merge extras
end

#owner_keyObject



42
43
44
# File 'app/models/in_order/aux/keys.rb', line 42

def owner_key
  InOrder::Aux::PolyKey.new(owner, default_name: 'owner')
end

#owner_paramsObject



34
35
36
# File 'app/models/in_order/aux/keys.rb', line 34

def owner_params
  owner_key.to_params
end

#scope_paramsObject



38
39
40
# File 'app/models/in_order/aux/keys.rb', line 38

def scope_params
  { scope: scope }
end

#to_aObject



30
31
32
# File 'app/models/in_order/aux/keys.rb', line 30

def to_a
  [ owner, scope ]
end

#to_hObject Also known as: to_params



21
22
23
# File 'app/models/in_order/aux/keys.rb', line 21

def to_h
  owner_params.merge scope_params
end

#to_sObject



26
27
28
# File 'app/models/in_order/aux/keys.rb', line 26

def to_s
  to_a.compact.map(&:to_s) * ', '
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/models/in_order/aux/keys.rb', line 17

def valid?
  to_a.any?
end