Class: Locomotive::Steam::ContentTypeFieldRepository
- Inherits:
-
Object
- Object
- Locomotive::Steam::ContentTypeFieldRepository
show all
- Includes:
- Models::Repository
- Defined in:
- lib/locomotive/steam/repositories/content_type_field_repository.rb
Instance Attribute Summary collapse
#adapter, #local_conditions, #scope
Instance Method Summary
collapse
#base_url, #build, #count, #create, #delete, #find, #first, #i18n_value_of, #inc, #initialize, #initialize_copy, #k, #last, #mapper, #prepare_conditions, #query, #update
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
8
9
10
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 8
def content_type
@content_type
end
|
Instance Method Details
#associations ⇒ Object
45
46
47
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 45
def associations
query { where(k(:type, :in) => %i(belongs_to has_many many_to_many)) }.all
end
|
#belongs_to ⇒ Object
37
38
39
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 37
def belongs_to
query { where(type: :belongs_to) }.all
end
|
#by_name(name) ⇒ Object
17
18
19
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 17
def by_name(name)
first { where(name: name) }
end
|
#dates_and_date_times ⇒ Object
33
34
35
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 33
def dates_and_date_times
query { where(k(:type, :in) => %i(date date_time)) }.all
end
|
#default ⇒ Object
70
71
72
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 70
def default
query { where(k(:default, :neq) => nil, k(:type, :in) => [:string, :text, :color, :select, :boolean, :email, :integer, :float]) }.all
end
|
#files ⇒ Object
25
26
27
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 25
def files
query { where(type: :file) }.all
end
|
#localized_names ⇒ Object
64
65
66
67
68
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 64
def localized_names
query { where(localized: true) }.all.map do |field|
field.type == :select ? [field.name, "#{field.name}_id"] : field.name
end.flatten
end
|
#many_to_many ⇒ Object
41
42
43
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 41
def many_to_many
query { where(type: :many_to_many) }.all
end
|
#no_associations ⇒ Object
49
50
51
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 49
def no_associations
query { where(k(:type, :nin) => %i(belongs_to has_many many_to_many)) }.all
end
|
#passwords ⇒ Object
29
30
31
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 29
def passwords
query { where(type: :password) }.all
end
|
#required ⇒ Object
60
61
62
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 60
def required
query { where(required: true) }.all
end
|
#select_options(name) ⇒ Object
74
75
76
77
78
79
80
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 74
def select_options(name)
if field = first { where(name: name, type: :select) }
field.select_options.all
else
nil
end
end
|
#selects ⇒ Object
21
22
23
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 21
def selects
query { where(type: :select) }.all
end
|
#unique ⇒ Object
53
54
55
56
57
58
|
# File 'lib/locomotive/steam/repositories/content_type_field_repository.rb', line 53
def unique
query { where(unique: true) }.all.inject({}) do |memo, field|
memo[field.name] = field
memo
end
end
|