Class: ActsAsCalculator::FindOwnedRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_calculator/find_owned_record.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(relation:, key:, scope: nil, owner: nil) ⇒ FindOwnedRecord

Returns a new instance of FindOwnedRecord.



9
10
11
12
13
14
# File 'lib/acts_as_calculator/find_owned_record.rb', line 9

def initialize(relation:, key:, scope: nil, owner: nil)
  @relation = relation
  @key = key.to_s
  @scope = (scope || DEFAULT_SCOPE).to_s
  @owner = owner
end

Class Method Details

.callObject



5
6
7
# File 'lib/acts_as_calculator/find_owned_record.rb', line 5

def self.call(...)
  new(...).call
end

Instance Method Details

#callObject



16
17
18
# File 'lib/acts_as_calculator/find_owned_record.rb', line 16

def call
  owned || global
end