Class: TranslationCms::OrderForm
- Inherits:
-
Object
- Object
- TranslationCms::OrderForm
- Defined in:
- lib/translation_cms/order_form.rb
Constant Summary collapse
- PREFIX_FIELDS =
[:assignment_type_id, :topic, :description, :paper_format_id, :sources_num, :academic_level_id, :line_spacing_id, :pages_num, :words_num, :is_page_summary, :is_night_calls, :material_type_id, :language_style_id, :customer_writers_ids, :coupon_value, :payment_type_id, :service_id, :skill_id, :specialist_type_id, :is_proofreading, :is_writer_sample, :is_urgent_assign, :extra_feature_ids].freeze
Instance Attribute Summary collapse
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#record ⇒ Object
Returns the value of attribute record.
Class Method Summary collapse
Instance Method Summary collapse
- #default? ⇒ Boolean
-
#initialize(kind, record) ⇒ OrderForm
constructor
A new instance of OrderForm.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(kind, record) ⇒ OrderForm
Returns a new instance of OrderForm.
22 23 24 25 |
# File 'lib/translation_cms/order_form.rb', line 22 def initialize(kind, record) @kind = kind @record = record end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/translation_cms/order_form.rb', line 31 def method_missing(method, *args, &block) is_value = false if method.to_s =~ /^value_/ method = method.to_s.gsub(/^value_/, '') is_value = true end method = "order_#{method}" if default? && PREFIX_FIELDS.include?(method.to_sym) if @record.respond_to?(method) is_value ? @record.send(method) : method.to_sym else super # You *must* call super if you don't handle the # method, otherwise you'll mess up Ruby's method # lookup. end end |
Instance Attribute Details
#kind ⇒ Object
Returns the value of attribute kind.
10 11 12 |
# File 'lib/translation_cms/order_form.rb', line 10 def kind @kind end |
#record ⇒ Object
Returns the value of attribute record.
10 11 12 |
# File 'lib/translation_cms/order_form.rb', line 10 def record @record end |
Class Method Details
.account(record) ⇒ Object
17 18 19 |
# File 'lib/translation_cms/order_form.rb', line 17 def account(record) new :account, record end |
.default(record) ⇒ Object
13 14 15 |
# File 'lib/translation_cms/order_form.rb', line 13 def default(record) new :default, record end |
Instance Method Details
#default? ⇒ Boolean
27 28 29 |
# File 'lib/translation_cms/order_form.rb', line 27 def default? @kind == :default end |