Module: RKit::ActiveRecordUtility::ActiveRecordExtend

Extended by:
ActiveRecordExtend
Included in:
ActiveRecordExtend
Defined in:
lib/r_kit/active_record_utility/active_record_extend.rb

Instance Method Summary collapse

Instance Method Details

#collection_finder(**options) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/r_kit/active_record_utility/active_record_extend.rb', line 27

def collection_finder **options
  collection = all
  collection = collection.pool options[:pool] if interfered? :pool
  collection = collection.published.publication_desc if interfered? :publisher
  collection = collection.series options[:series] if interfered? :series
  collection
end

#instance_finder(**options) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/r_kit/active_record_utility/active_record_extend.rb', line 35

def instance_finder **options
  if interfered? :tag
    tagged options[:tag]
  else
    find_by id: options[:id]
  end
end

#interfered?(utility) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
# File 'lib/r_kit/active_record_utility/active_record_extend.rb', line 20

def interfered? utility
  RKit::ActiveRecordUtility::Base.const_get(utility.classify).interfered? self
rescue NameError
  false
end

#interferences_options_get(utility = @_active_record_utilities_self) ⇒ Object



15
16
17
# File 'lib/r_kit/active_record_utility/active_record_extend.rb', line 15

def interferences_options_get utility = @_active_record_utilities_self
  instance_variable_get "@_active_record_utilities_#{ utility }_options"
end

#interferences_options_set(utility, **options) ⇒ Object



10
11
12
13
# File 'lib/r_kit/active_record_utility/active_record_extend.rb', line 10

def interferences_options_set utility, **options
  instance_variable_set "@_active_record_utilities_self", utility
  instance_variable_set "@_active_record_utilities_#{ utility }_options", options
end