lib/katapult/element.rb in katapult-0.3.0 vs lib/katapult/element.rb in katapult-0.4.0

- old
+ new

@@ -8,14 +8,13 @@ class Element UnknownOptionError = Class.new(StandardError) UnknownFormattingError = Class.new(StandardError) - attr_accessor :name, :options - attr_reader :application_model + attr_accessor :name, :options, :application_model - # Improve semantics in element classes + # Use #options for DSL/API, attr_accessor for internal attributes class << self alias_method :options, :attr_accessor end @@ -26,29 +25,25 @@ set_attributes(options) yield(self) if block_given? end - def set_application_model(app_model) - @application_model = app_model - end - def name(kind = nil) machine_name = @name.underscore human_name = machine_name.humanize.downcase case kind.to_s - when '' then @name - when 'symbol' then ":#{machine_name}" - when 'symbols' then ":#{machine_name.pluralize}" - when 'variable' then machine_name - when 'variables' then machine_name.pluralize - when 'ivar' then "@#{machine_name}" - when 'ivars' then "@#{machine_name.pluralize}" - when 'human' then human_name - when 'humans' then human_name.pluralize - when 'class' then machine_name.classify - when 'classes' then machine_name.classify.pluralize + when '' then @name ## Example + when 'symbol' then ":#{machine_name}" # :user_task + when 'symbols' then ":#{machine_name.pluralize}" # :user_tasks + when 'variable' then machine_name # user_task + when 'variables' then machine_name.pluralize # user_tasks + when 'ivar' then "@#{machine_name}" # @user_task + when 'ivars' then "@#{machine_name.pluralize}" # @user_tasks + when 'human' then human_name # user task + when 'humans' then human_name.pluralize # user tasks + when 'class' then machine_name.classify # UserTask + when 'classes' then machine_name.classify.pluralize # UserTasks else raise UnknownFormattingError, "Unknown name formatting: #{ kind.inspect }" end end private