Class: ActiveData::Attributes::Localized

Inherits:
Base
  • Object
show all
Defined in:
lib/active_data/attributes/localized.rb

Instance Attribute Summary

Attributes inherited from Base

#name, #options

Instance Method Summary collapse

Methods inherited from Base

#default, #default_blank?, #initialize, #type, #type_cast, #values

Constructor Details

This class inherits a constructor from ActiveData::Attributes::Base

Instance Method Details

#default_value(*args) ⇒ Object



5
6
7
# File 'lib/active_data/attributes/localized.rb', line 5

def default_value *args
  {}
end

#generate_class_methods(context) ⇒ Object



37
38
# File 'lib/active_data/attributes/localized.rb', line 37

def generate_class_methods context
end

#generate_instance_methods(context) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/active_data/attributes/localized.rb', line 9

def generate_instance_methods context
  context.class_eval "    def \#{name}_translations\n      read_attribute(:\#{name})\n    end\n\n    def \#{name}_translations= value\n      write_attribute(:\#{name}, value)\n    end\n\n    def \#{name}\n      read_localized_attribute(:\#{name})\n    end\n\n    def \#{name}= value\n      write_localized_attribute(:\#{name}, value)\n    end\n\n    def \#{name}?\n      read_localized_attribute(:\#{name}).present?\n    end\n\n    def \#{name}_before_type_cast\n      read_localized_attribute_before_type_cast(:\#{name})\n    end\n  EOS\nend\n"