Class: DcDummy

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document
Defined in:
app/models/dc_dummy.rb

Overview

Schema information

Collection name: dc_dummy : Collection name used when form does not belong to database model.

_id                  BSON::ObjectId       _id

Which is not collection at all. DcDummy model is used for entering data on forms where data will not be saved to database but will instead be processed by custom made routine. For example entering begin and end date on report.

Example (as used in forms):

table: dc_dummy
title: Enter time period

  form:
    actions:
      1:
        type: ajax
        method: post
        controller: reports
        action: do_some_report
        caption: Run report

    fields:
      10:
        name: date_start
        type: date_picker
        caption: Start date
      20:
        name: date_end
        type: date_picker
        caption: End date

And suppose your report saved data to file named public/report.pdf. Put this line at the end of do_some_report method:

render inline: { :window_report => '/report.pdf' }.to_json, formats: 'js'

As result report.pdf file will be opened in new browser window.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object

Method missing will return value if value defined by m parameter is saved to



91
92
93
94
95
96
97
98
99
100
# File 'app/models/dc_dummy.rb', line 91

def method_missing(m, *args, &block) #:nodoc:
  @internals ||= {}
  m = m.to_s
  if m.match('=')
    m.chomp!('=')
    @internals[m] = args.first
  else
    @internals[m]
  end   
end

Instance Method Details

#respond_to?(m) ⇒ Boolean

Respond_to should always return true.

Returns:

  • (Boolean)


72
73
74
# File 'app/models/dc_dummy.rb', line 72

def respond_to?(m)
  true
end

#send(field, value = nil) ⇒ Object

Redefine send method. Send is used to assign value by cmsedit controller.



79
80
81
82
83
84
85
# File 'app/models/dc_dummy.rb', line 79

def send(field,value=nil)
  if field.to_s.match('=')
    field.chomp!('=')
    @internals ||= {}
    @internals[field] = value
  end
end