Class: Kms::EntryDrop
- Inherits:
-
Liquor::Drop
- Object
- Liquor::Drop
- Kms::EntryDrop
show all
- Defined in:
- lib/drops/kms/entry_drop.rb
Defined Under Namespace
Classes: Scope
Instance Method Summary
collapse
Constructor Details
#initialize(source) ⇒ EntryDrop
Returns a new instance of EntryDrop.
54
55
56
57
58
59
60
61
|
# File 'lib/drops/kms/entry_drop.rb', line 54
def initialize(source)
self.class.instance_eval do
source.model.fields.pluck(:liquor_name).each do |field_name|
export field_name.to_sym
end
end
super(source)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
63
64
65
66
|
# File 'lib/drops/kms/entry_drop.rb', line 63
def method_missing(name, *args, &block)
field = source.model.fields.find_by(liquor_name: name.to_s)
field ? field.get_value(source) : super
end
|
Instance Method Details
#created_at ⇒ Object
72
73
74
|
# File 'lib/drops/kms/entry_drop.rb', line 72
def created_at
source.created_at.to_s
end
|
#model_collection_name ⇒ Object
76
77
78
|
# File 'lib/drops/kms/entry_drop.rb', line 76
def model_collection_name
source.model.collection_name
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
68
69
70
|
# File 'lib/drops/kms/entry_drop.rb', line 68
def respond_to_missing?(method_name, include_private = false)
source.model.fields.where(liquor_name: method_name.to_s).exists? || super
end
|