Module: Linker::Attributes
- Extended by:
- ActiveSupport::Concern
- Includes:
- ConfigurationMethods
- Included in:
- Linker
- Defined in:
- lib/linker/forms/attributes.rb
Constant Summary collapse
- USELESS_COLUMNS_REGEX =
%r{^(updated_at|created_at)$}
Instance Method Summary collapse
- #get_main_model ⇒ Object
- #prepare_attrs ⇒ Object
- #set_delegations ⇒ Object
- #set_reader_for_main_model ⇒ Object
Instance Method Details
#get_main_model ⇒ Object
10 11 12 |
# File 'lib/linker/forms/attributes.rb', line 10 def get_main_model @main_model ||= self.class._main_model.constantize end |
#prepare_attrs ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/linker/forms/attributes.rb', line 14 def prepare_attrs get_main_model set_reader_for_main_model set_delegations set_fields_for_methods(map_has_many_associations) set_fields_for_methods(map_belongs_to_associations, true) set_fields_for_methods(map_has_one_associations, true) end |
#set_delegations ⇒ Object
29 30 31 32 |
# File 'lib/linker/forms/attributes.rb', line 29 def set_delegations # Delegate fields for main model filter_columns(@main_model).each{|c| delegate_attr(c, @main_model.to_s.underscore) } end |
#set_reader_for_main_model ⇒ Object
23 24 25 26 27 |
# File 'lib/linker/forms/attributes.rb', line 23 def set_reader_for_main_model #ap "criando reader for main model #{@main_model.to_s.underscore}" # Create attr reader for main model self.class.__send__(:attr_reader, @main_model.to_s.underscore) end |