Class: ODDB::Html::State::Drugs::Admin::Product

Inherits:
Global
  • Object
show all
Defined in:
lib/oddb/html/state/drugs/admin/product.rb

Constant Summary collapse

VIEW =
View::Drugs::Admin::Product

Constants inherited from Global

Global::GLOBAL_MAP, Global::LIMIT

Instance Attribute Summary

Attributes inherited from Global

#passed_turing_test

Attributes included from LoginMethods

#desired_input

Instance Method Summary collapse

Methods inherited from Global

transparent_login

Methods included from Events

#_compare, #_complete, #_explain_ddd_price, #_explain_price, #_fachinfo, #_feedback, #_package, #_package_by_code, #_package_infos, #_patinfo, #_products, #_remote, #_remote_comparables, #_remote_infos, #_remote_package, #_remote_packages, #_search, #_search_append_products, #_search_append_sequences, #_search_by, #_search_local, #_search_remote, #_tax_factor, #compare_remote, #ddd, #limited?, #navigation, #search

Methods inherited from Global

#_download, #compare, #explain_ddd_price, #explain_price, #fachinfo, #feedback, #home, #limit_state, #limited?, #logout, #method_missing, #navigation, #package, #package_infos, #partitioned_keys, #patinfo, #proceed_export, #proceed_poweruser, #products, #remote_infos, #sequence

Methods included from PayPal::Checkout

#ajax_autofill, #checkout, #checkout_keys, #checkout_mandatory, #collect, #create_user

Methods included from LoginMethods

#login_

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ODDB::Html::State::Global

Instance Method Details

#check_modelObject



14
15
16
17
18
# File 'lib/oddb/html/state/drugs/admin/product.rb', line 14

def check_model
  if(@model.uid.to_s != @session.user_input(:uid))
    @errors.store :uid, create_error(:e_state_expired, :uid, nil)
  end
end

#direct_eventObject



19
20
21
22
23
24
25
# File 'lib/oddb/html/state/drugs/admin/product.rb', line 19

def direct_event
  direct_event = [:product]
  if(uid = @model.uid)
    direct_event.push([:uid, uid])
  end
  direct_event
end

#productObject



44
45
46
47
48
49
50
# File 'lib/oddb/html/state/drugs/admin/product.rb', line 44

def product
  if((uid = @session.user_input(:uid)) && @model.uid.to_s == uid)
    self
  else
    super
  end
end

#updateObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/oddb/html/state/drugs/admin/product.rb', line 26

def update
  value = user_input :company
  error_check_and_store(:company, value, [:company])
  unless error?
    set = if(company = ODDB::Business::Company.find_by_name(value))
            @model.company = company
          else
            @errors.store :company, create_error(:e_unknown_company,
                                                 :company, value)
            nil
          end
    unless(set.nil?)
      @model.data_origins.store :company, @session.user.email
      @model.save
    end
  end
  self
end