Module: Card::Set::Type::Set

Extended by:
Card::Set
Includes:
SearchType
Defined in:
tmpsets/set/mod016-standard/type/set.rb

Constant Summary

Constants included from Format

Format::TEMPLATE_DIR

Instance Method Summary collapse

Methods included from I18nScope

#mod_name, #scope

Methods included from Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set

Methods included from Helpers

#abstract_set?, #all_set?, #num_set_parts, #shortname, #underscore

Methods included from AdvancedApi

#attachment, #ensure_set, #stage_method

Methods included from Format

#all_set_format_mod!, #before, #define_on_format, #format, layout_method_name, #register_set_format, #view, #view_for_override, view_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket

Methods included from Card::Set::Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Methods included from SearchType

#count, #get_query, #item_cards, #item_names, #item_type, #query

Instance Method Details

#all_members_followed?Boolean

Returns:

  • (Boolean)


326
327
328
# File 'tmpsets/set/mod016-standard/type/set.rb', line 326

def all_members_followed?
  all_members_followed_by? Auth.current_id
end

#all_members_followed_by?(user_id = nil) ⇒ Boolean

Returns:

  • (Boolean)


330
331
332
333
334
335
336
337
338
339
# File 'tmpsets/set/mod016-standard/type/set.rb', line 330

def all_members_followed_by? user_id=nil
  return false unless prototype.followed_by?(user_id)
  return true if set_followed_by? user_id
  broader_sets.each do |b_s|
    if (set_card = Card.fetch(b_s)) && set_card.set_followed_by?(user_id)
      return true
    end
  end
  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



297
298
299
# File 'tmpsets/set/mod016-standard/type/set.rb', line 297

def all_user_ids_with_rule_for setting_code
  Card.all_user_ids_with_rule_for self, setting_code
end

#broader_setsObject



352
353
354
# File 'tmpsets/set/mod016-standard/type/set.rb', line 352

def broader_sets
  prototype.set_names[1..-1]
end

#default_follow_set_cardObject



233
234
235
# File 'tmpsets/set/mod016-standard/type/set.rb', line 233

def default_follow_set_card
  self
end

#follow_labelObject



266
267
268
269
270
271
272
# File 'tmpsets/set/mod016-standard/type/set.rb', line 266

def follow_label
  if (klass = subclass_for_set)
    klass.follow_label cardname.left
  else
    ""
  end
end

#follow_rule_name(user = nil) ⇒ Object



274
275
276
277
278
279
280
281
282
283
284
# File 'tmpsets/set/mod016-standard/type/set.rb', line 274

def follow_rule_name user=nil
  if user
    if user.is_a? 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

Returns:

  • (Boolean)


229
230
231
# File 'tmpsets/set/mod016-standard/type/set.rb', line 229

def followed_by? user_id=nil
  all_members_followed_by? user_id
end

#inheritable?Boolean

Returns:

  • (Boolean)


237
238
239
240
241
# File 'tmpsets/set/mod016-standard/type/set.rb', line 237

def inheritable?
  return true if junction_only?
  cardname.trunk_name.junction? &&
    cardname.tag_name.key == Card::Set::Self.pattern.key
end

#junction_only?Boolean

Returns:

  • (Boolean)


250
251
252
253
254
255
256
# File 'tmpsets/set/mod016-standard/type/set.rb', line 250

def junction_only?
  if @junction_only.nil?
    @junction_only = subclass_for_set.junction_only
  else
    @junction_only
  end
end

#labelObject



258
259
260
261
262
263
264
# File 'tmpsets/set/mod016-standard/type/set.rb', line 258

def label
  if (klass = subclass_for_set)
    klass.label cardname.left
  else
    ""
  end
end

#prototypeObject



356
357
358
359
# File 'tmpsets/set/mod016-standard/type/set.rb', line 356

def prototype
  opts = subclass_for_set.prototype_args cardname.trunk_name
  Card.fetch opts[:name], new: opts
end


361
362
363
364
365
366
367
# File 'tmpsets/set/mod016-standard/type/set.rb', line 361

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

#set_followed?Boolean

Returns:

  • (Boolean)


341
342
343
# File 'tmpsets/set/mod016-standard/type/set.rb', line 341

def set_followed?
  set_followed_by? Auth.current_id
end

#set_followed_by?(user_id = nil) ⇒ Boolean

Returns:

  • (Boolean)


345
346
347
348
349
350
# File 'tmpsets/set/mod016-standard/type/set.rb', line 345

def set_followed_by? user_id=nil
  (
    user_id &&
    (user = Card.find(user_id)) && Card.fetch(follow_rule_name(user.name))
  ) || Card.fetch(follow_rule_name)
end

#setting_codenames_by_groupObject



301
302
303
304
305
306
307
308
309
310
311
# File 'tmpsets/set/mod016-standard/type/set.rb', line 301

def setting_codenames_by_group
  result = {}
  Card::Setting.groups.each do |group, settings|
    visible_settings =
      settings.reject { |s| !s || !s.applies_to_cardtype(prototype.type_id) }
    unless visible_settings.empty?
      result[group] = visible_settings.map(&:codename)
    end
  end
  result
end

#subclass_for_setObject



243
244
245
246
247
248
# File 'tmpsets/set/mod016-standard/type/set.rb', line 243

def subclass_for_set
  current_set_pattern_code = tag.codename
  Card.set_patterns.find do |set|
    current_set_pattern_code == set.pattern_code
  end
end

#visible_setting_codenamesObject



313
314
315
316
317
318
# File 'tmpsets/set/mod016-standard/type/set.rb', line 313

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



320
321
322
323
324
# File 'tmpsets/set/mod016-standard/type/set.rb', line 320

def visible_settings group
  Card::Setting.groups[group].reject do |setting|
    !setting || !setting.applies_to_cardtype(prototype.type_id)
  end
end