Module: Anaconda::Model::InstanceMethods
- Defined in:
- lib/anaconda/anaconda_for.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/anaconda/anaconda_for.rb', line 68
def method_missing(method, *args, &block)
checking_column = checking_method = nil
if self.class.anaconda_columns.present? && self.class.anaconda_columns.any? do |column|
checking_column = column
Anaconda::MagicMethods.any? do |magic_method|
checking_method = magic_method
"#{column.to_s}_#{magic_method.to_s}" == method.to_s
end
end
case checking_method
when :url
anaconda_url(checking_column, *args)
when :download_url
anaconda_download_url(checking_column)
when :anaconda_default_base_key
anaconda_default_base_key_for(checking_column)
else
super
end
else
super
end
end
|
Instance Method Details
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/anaconda/anaconda_for.rb', line 100
def anaconda_form_data_for( anaconda_column )
if self.anaconda_columns.include? anaconda_column.to_sym
options = self.class.anaconda_options[anaconda_column.to_sym].dup
options[:base_key] = self.send(options[:base_key].to_s) if options[:base_key].kind_of? Symbol
uploader = Anaconda::S3Uploader.new(options)
fields = uploader.fields
fields[:post_url] = uploader.url
fields
else
raise "#{anaconda_column} not configured for anaconda. Misspelling or did you forget to add the anaconda_for call for this field?"
end
end
|
92
93
94
95
96
97
98
|
# File 'lib/anaconda/anaconda_for.rb', line 92
def anaconda_form_data_for_all_columns
form_data = {}
self.anaconda_columns.each do |column|
form_data[column.to_sym] = anaconda_form_data_for column
end
form_data
end
|