Module: ErpForms::Extensions::ActiveRecord::ActsAsDynamicFormModel::InstanceMethods

Defined in:
lib/erp_forms/extensions/active_record/acts_as_dynamic_form_model.rb

Instance Method Summary collapse

Instance Method Details

#allow_comments?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/erp_forms/extensions/active_record/acts_as_dynamic_form_model.rb', line 32

def allow_comments?
  dynamic_model.allow_comments
end

#allow_files?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/erp_forms/extensions/active_record/acts_as_dynamic_form_model.rb', line 36

def allow_files?
  dynamic_model.allow_files
end

#assign_all_attributes(params, ignored_params = []) ⇒ Object

handles both static and dynamic attributes



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/erp_forms/extensions/active_record/acts_as_dynamic_form_model.rb', line 49

def assign_all_attributes(params, ignored_params=[])    
  params.each do |k,v|
    k = k.to_s
    unless ignored_params.include?(k) or k == '' or k == '_'
      if self.attributes.include?(k)
        self.send(k + '=', v) 
      else
        if ['created_by','updated_by','created_at','updated_at','created_with_form_id','updated_with_form_id'].include?(k)
          key = k + '='
        else
          key = DynamicDatum::DYNAMIC_ATTRIBUTE_PREFIX + k + '='
        end
        
        self.data.send(key, v) 
      end
    end
  end

  self
end

#dynamic_modelObject



20
21
22
# File 'lib/erp_forms/extensions/active_record/acts_as_dynamic_form_model.rb', line 20

def dynamic_model
  self.respond_to?(:dynamic_form_model) ? dynamic_form_model : DynamicFormModel.find_by_model_name(self.class.name)
end

#file_security_defaultObject



40
41
42
# File 'lib/erp_forms/extensions/active_record/acts_as_dynamic_form_model.rb', line 40

def file_security_default
  dynamic_model.file_security_default
end

#roleObject



28
29
30
# File 'lib/erp_forms/extensions/active_record/acts_as_dynamic_form_model.rb', line 28

def role
  dynamic_model.role
end

#role_iidObject



24
25
26
# File 'lib/erp_forms/extensions/active_record/acts_as_dynamic_form_model.rb', line 24

def role_iid
  dynamic_model.role_iid
end

#save_all_attributes(params, ignored_params = []) ⇒ Object

handles both static and dynamic attributes



71
72
73
74
# File 'lib/erp_forms/extensions/active_record/acts_as_dynamic_form_model.rb', line 71

def save_all_attributes(params, ignored_params=[])
  self.assign_all_attributes(params, ignored_params)
  (self.valid? and self.save) ? self : nil
end

#show_in_multitaskObject



44
45
46
# File 'lib/erp_forms/extensions/active_record/acts_as_dynamic_form_model.rb', line 44

def show_in_multitask
  dynamic_model.show_in_multitask
end