Class: Column
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Column
- Extended by:
- Zena::Acts::Secure
- Includes:
- Property::StoredColumn, RubyLess
- Defined in:
- app/models/column.rb
Constant Summary collapse
- TYPES_FOR_FORM =
%w{string datetime integer float}
- INDICES_FOR_FORM =
%w{string ml_string datetime integer float}
- FIELD_INDICES =
[]
Class Method Summary collapse
-
.add_field_index(*args) ⇒ Object
Declare a new index table or field.
- .indices_for_form ⇒ Object
- .roles_for_form ⇒ Object
Instance Method Summary collapse
- #export ⇒ Object
-
#index_name ⇒ Object
Used to display index name in forms.
- #kpath ⇒ Object
- #type_cast(value) ⇒ Object
Methods included from Zena::Acts::Secure
secure_scope, secure_write_scope, visitor=
Methods included from Zena::Acts::Secure::SecureResult
#construct_id_map, #secure_result
Class Method Details
.add_field_index(*args) ⇒ Object
Declare a new index table or field
47 48 49 50 51 |
# File 'app/models/column.rb', line 47 def add_field_index(*args) args.flatten.each do |idx| FIELD_INDICES << idx end end |
.indices_for_form ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/models/column.rb', line 37 def indices_for_form [ ['field', FIELD_INDICES.map {|i| [i, ".#{i}"]}], ['key/value', INDICES_FOR_FORM.map {|i| [i, i]}] ] end |
Instance Method Details
#export ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'app/models/column.rb', line 63 def export root = current_site.root_node { 'ptype' => ptype, 'index' => index, 'comment' => root.unparse_assets(comment, root, 'comment') } end |
#index_name ⇒ Object
Used to display index name in forms
59 60 61 |
# File 'app/models/column.rb', line 59 def index_name self.index.to_s.gsub(/\A\./,'') end |
#kpath ⇒ Object
54 55 56 |
# File 'app/models/column.rb', line 54 def kpath @kpath ||= role.kpath end |
#type_cast(value) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/models/column.rb', line 72 def type_cast(value) if ptype == 'datetime' if value.blank? nil elsif value.kind_of?(Time) value elsif value.kind_of?(String) value.to_utc(_(Zena::Use::Dates::DATETIME), visitor.tz) else nil end else nil end end |