Module: Card::Set::Type::Set
- Extended by:
- Card::Set
- Includes:
- SearchType
- Defined in:
- tmpsets/set/mod007-05_standard/type/set.rb
Instance Method Summary
collapse
Methods included from Card::Set
abstract_set?, all_set?, card_accessor, card_reader, card_writer, clean_empty_module_from_hash, clean_empty_modules, define_active_job, define_event_method, define_event_perform_later_method, define_on_format, ensure_set, event, extended, format, process_base_module_list, process_base_modules, register_set, register_set_format, shortname, view, write_tmp_file
Methods included from SearchType
#count, #get_query, #item_cards, #item_names, #item_type, #query
Instance Method Details
#all_members_followed? ⇒ Boolean
305
306
307
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 305
def all_members_followed?
all_members_followed_by? Auth.current_id
end
|
#all_members_followed_by?(user_id = nil) ⇒ Boolean
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 309
def all_members_followed_by? user_id = nil
if !prototype.followed_by? user_id
return false
elsif set_followed_by? user_id
return true
else
broader_sets.each do |b_s|
if (set_card = Card.fetch(b_s)) && set_card.set_followed_by?(user_id)
return true
end
end
end
return false
end
|
#all_user_ids_with_rule_for(setting_code) ⇒ Object
def to_following_item_name args
left_part = follow_rule_name( args[:user] )
option = args[:option] || if (rule_card = Card.fetch(left_part))
rule_card.content
else
Card[:nothing].name
end
"#{left_part}+#{option}"
end
276
277
278
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 276
def all_user_ids_with_rule_for setting_code
Card.all_user_ids_with_rule_for self, setting_code
end
|
#broader_sets ⇒ Object
333
334
335
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 333
def broader_sets
prototype.set_names[1..-1]
end
|
#default_follow_set_card ⇒ Object
207
208
209
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 207
def default_follow_set_card
self
end
|
#follow_label ⇒ Object
245
246
247
248
249
250
251
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 245
def follow_label
if klass = subclass_for_set
klass.follow_label cardname.left
else
''
end
end
|
#follow_rule_name(user = nil) ⇒ Object
253
254
255
256
257
258
259
260
261
262
263
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 253
def follow_rule_name user=nil
if user
if user.kind_of? String
"#{name}+#{user}+#{Card[:follow].name}"
else
"#{name}+#{user.name}+#{Card[:follow].name}"
end
else
"#{name}+#{Card[:all].name}+#{Card[:follow].name}"
end
end
|
#followed_by?(user_id = nil) ⇒ Boolean
202
203
204
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 202
def followed_by? user_id = nil
all_members_followed_by? user_id
end
|
#inheritable? ⇒ Boolean
211
212
213
214
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 211
def inheritable?
return true if junction_only?
cardname.trunk_name.junction? and cardname.tag_name.key == Card::SelfSet.pattern.key
end
|
#junction_only? ⇒ Boolean
223
224
225
226
227
228
229
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 223
def junction_only?()
if @junction_only.nil?
@junction_only = subclass_for_set.junction_only
else
@junction_only
end
end
|
237
238
239
240
241
242
243
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 237
def label
if klass = subclass_for_set
klass.label cardname.left
else
''
end
end
|
#prototype ⇒ Object
338
339
340
341
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 338
def prototype
opts = subclass_for_set.prototype_args self.cardname.trunk_name
Card.fetch opts[:name], :new=>opts
end
|
343
344
345
346
347
348
349
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 343
def related_sets with_self = false
if subclass_for_set.anchorless?
prototype.related_sets with_self
else
left(:new=>{}).related_sets with_self
end
end
|
#reset_set_patterns ⇒ Object
231
232
233
234
235
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 231
def reset_set_patterns
Card.members( key ).each do |mem|
Card.expire mem
end
end
|
#set_followed? ⇒ Boolean
324
325
326
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 324
def set_followed?
set_followed_by? Auth.current_id
end
|
#set_followed_by?(user_id = nil) ⇒ Boolean
328
329
330
331
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 328
def set_followed_by? user_id = nil
return ( user_id && (user = Card.find(user_id)) && Card.fetch(follow_rule_name(user.name)) ) ||
Card.fetch(follow_rule_name)
end
|
#setting_codenames_by_group ⇒ Object
281
282
283
284
285
286
287
288
289
290
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 281
def setting_codenames_by_group
result = {}
Card::Setting.groups.each do |group, settings|
visible_settings = settings.reject { |s| !s or !s.applies_to_cardtype(prototype.type_id) }
unless visible_settings.empty?
result[group] = visible_settings.map { |s| s.codename }
end
end
result
end
|
#subclass_for_set ⇒ Object
216
217
218
219
220
221
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 216
def subclass_for_set
set_class_key = tag.codename
Card.set_patterns.find do |sub|
cardname.tag_name.key == sub.pattern.key
end
end
|
#visible_setting_codenames ⇒ Object
292
293
294
295
296
297
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 292
def visible_setting_codenames
@visible_settings ||=
Card::Setting.groups.values.flatten.compact.reject do |setting|
!setting.applies_to_cardtype(prototype.type_id)
end.map(&:codename)
end
|
#visible_settings(group) ⇒ Object
299
300
301
302
303
|
# File 'tmpsets/set/mod007-05_standard/type/set.rb', line 299
def visible_settings group
Card::Setting.groups[group].reject do |setting|
!setting or !setting.applies_to_cardtype(prototype.type_id)
end
end
|