Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/ruboss4ruby/active_record_default_methods.rb
Overview
We also add support for serializing model methods along the lines of:
class Project < ActiveRecord::Base
default_methods :foobar
def
'foobar'
end
end
When you do to_fxml on this model method foobar will be automatically serialized as a simple attribute
Class Method Summary collapse
-
.default_methods(*args) ⇒ Object
default methods hook.
-
.defaults_hash(already_included = [], ignore_default_methods = nil) ⇒ Object
default methods hook.
Class Method Details
.default_methods(*args) ⇒ Object
default methods hook
19 20 21 22 23 24 25 26 |
# File 'lib/ruboss4ruby/active_record_default_methods.rb', line 19 def default_methods(*args) methods = *args.dup module_eval <<-END def self.default_methods_array return [#{methods.inspect}].flatten end END end |
.defaults_hash(already_included = [], ignore_default_methods = nil) ⇒ Object
default methods hook
29 30 31 32 33 34 35 |
# File 'lib/ruboss4ruby/active_record_default_methods.rb', line 29 def defaults_hash(already_included = [], ignore_default_methods = nil) defaults_hash = {:include => {}} unless ignore_default_methods defaults_hash[:methods] = self.default_methods_array if self.respond_to?(:default_methods_array) end defaults_hash end |