Class: Marty::Base
Direct Known Subclasses
ApiAuth, ApiConfig, BaseRule, Config, DataGrid, EnumEventOperation, Event, GridIndexBoolean, GridIndexInt4range, GridIndexInteger, GridIndexNumrange, GridIndexString, ImportType, Log, Posting, PostingType, Promise, Role, Script, Tag, Token, User, UserRole
Constant Summary
collapse
- MCFLY_PT_SIG =
[1, 1]
- COUNT_SIG =
FIXME: hacky signatures for AR queries
[0, 0]
- DISTINCT_SIG =
[0, 100]
- FIRST_SIG =
[0, 1]
- GROUP_SIG =
[1, 100]
- JOINS_SIG =
[1, 100]
- LAST_SIG =
[0, 1]
- LIMIT_SIG =
[1, 1]
- NOT_SIG =
[1, 100]
- ORDER_SIG =
[1, 100]
- PLUCK_SIG =
[1, 100]
- SELECT_SIG =
[1, 100]
- WHERE_SIG =
[0, 100]
Class Attribute Summary collapse
Class Method Summary
collapse
joins, old_joins
Class Attribute Details
.struct_attrs ⇒ Object
Returns the value of attribute struct_attrs.
26
27
28
|
# File 'app/models/marty/base.rb', line 26
def struct_attrs
@struct_attrs
end
|
Class Method Details
.get_final_attrs ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'app/models/marty/base.rb', line 36
def self.get_final_attrs
final_attrs = get_struct_attrs
return final_attrs if final_attrs.present?
raise "Marty::Base: no attributes for #{self}"
end
|
.get_struct_attrs ⇒ Object
29
30
31
32
33
34
|
# File 'app/models/marty/base.rb', line 29
def self.get_struct_attrs
self.struct_attrs ||=
self.attribute_names - Mcfly::COLUMNS.to_a -
(self.const_defined?('MCFLY_UNIQUENESS') &&
self.const_get('MCFLY_UNIQUENESS') || []).map(&:to_s)
end
|
.make_hash(inst) ⇒ Object
59
60
61
62
|
# File 'app/models/marty/base.rb', line 59
def self.make_hash(inst)
fa = get_final_attrs
inst.attributes.slice(*fa)
end
|
.make_openstruct(inst) ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'app/models/marty/base.rb', line 64
def self.make_openstruct(inst)
return nil unless inst
fa = get_final_attrs
os = OpenStruct.new(inst.attributes.slice(*fa))
if self == Marty::DataGrid
def os.lookup_grid_distinct_entry(pt, params)
dgh = self.to_h.stringify_keys.slice(
"id", "group_id", "created_dt", "metadata", "data_type")
Marty::DataGrid.lookup_grid_distinct_entry_h(pt, params, dgh)
end
end
os
end
|
.mcfly_pt(pt) ⇒ Object
5
6
7
8
|
# File 'app/models/marty/base.rb', line 5
def self.mcfly_pt(pt)
tb = self.table_name
self.where("#{tb}.obsoleted_dt >= ? AND #{tb}.created_dt < ?", pt, pt)
end
|