Class: Runo::Set::Dynamic
- Includes:
- Runo::Set
- Defined in:
- lib/set/dynamic.rb,
lib/_widget/done.rb,
lib/_widget/navi.rb,
lib/_widget/login.rb,
lib/_widget/submit.rb,
lib/_widget/message.rb,
lib/_widget/view_ym.rb,
lib/_widget/action_create.rb
Overview
- Author
-
Akira FUNAI
- Copyright
-
Copyright © 2009-2010 Akira FUNAI
Constant Summary
Constants inherited from Field
Instance Attribute Summary collapse
-
#storage ⇒ Object
readonly
Returns the value of attribute storage.
-
#workflow ⇒ Object
readonly
Returns the value of attribute workflow.
Attributes inherited from Field
Instance Method Summary collapse
- #commit(type = :temp) ⇒ Object
- #get(arg = {}) ⇒ Object
-
#initialize(meta = {}) ⇒ Dynamic
constructor
A new instance of Dynamic.
- #meta_href ⇒ Object
- #meta_tid ⇒ Object
Methods included from Runo::Set
#collect, #each, #errors, #inspect_items, #item, #meta_base_path, #meta_dir, #meta_path, #pending?, #val
Methods inherited from Field
#[], #[]=, #create, #default_action, #delete, #empty?, #errors, #find_ancestor, h, #inspect, instance, #item, #load, #load_default, #meta_admins, #meta_client, #meta_folder, #meta_full_name, #meta_group, #meta_name, #meta_owner, #meta_owners, #meta_roles, #meta_sd, #meta_short_name, #pending?, #permit?, #post, #update, #val, #valid?
Methods included from I18n
_, bindtextdomain, domain, domain=, find_msg, lang, lang=, merge_msg!, msg, n_, parse_msg, po_dir, po_dir=
Constructor Details
#initialize(meta = {}) ⇒ Dynamic
Returns a new instance of Dynamic.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/set/dynamic.rb', line 12 def initialize( = {}) @meta = @storage = Runo::Storage.instance self @workflow = Runo::Workflow.instance self @meta = @workflow.class.const_get(:DEFAULT_META).merge @meta @item_object = {} my[:item] ||= { 'default' => {:item => {}} } my[:item].each {|type, | [:item] = @workflow.default_sub_items.merge [:item] } my[:p_size] = [:max] if [:max] my[:preview] = :optional if Array([:tokens]).include?('may_preview') my[:preview] = :mandatory if Array([:tokens]).include?('should_preview') my[:order] = 'id' if Array([:tokens]).include? 'asc' my[:order] = '-id' if Array([:tokens]).include? 'desc' end |
Instance Attribute Details
#storage ⇒ Object (readonly)
Returns the value of attribute storage.
10 11 12 |
# File 'lib/set/dynamic.rb', line 10 def storage @storage end |
#workflow ⇒ Object (readonly)
Returns the value of attribute workflow.
10 11 12 |
# File 'lib/set/dynamic.rb', line 10 def workflow @workflow end |
Instance Method Details
#commit(type = :temp) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/set/dynamic.rb', line 52 def commit(type = :temp) @workflow.before_commit items = pending_items items.each {|id, item| item.commit(:temp) || next case type when :temp store(id, item) if @storage.is_a? Runo::Storage::Temp when :persistent store(id, item) item.commit :persistent end } if valid? @result = (@action == :update) ? items : @action @action = nil if type == :persistent @workflow.after_commit self end end |
#get(arg = {}) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/set/dynamic.rb', line 45 def get(arg = {}) if !arg[:conds].is_a?(::Hash) || arg[:conds].empty? arg[:conds] = my[:conds].is_a?(::Hash) ? my[:conds].dup : {} end super end |
#meta_href ⇒ Object
33 34 35 |
# File 'lib/set/dynamic.rb', line 33 def "#{Runo.uri}#{my[:path]}/" end |
#meta_tid ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/set/dynamic.rb', line 37 def unless @meta[:tid] t = Time.now @meta[:tid] = t.strftime('%m%d%H%M%S.') + t.usec.to_s end @meta[:tid] end |