Sha256: e6c0f51d2280eb3c13f32fd4fc1a7aae12c806aaf6ec0162fc48e1d3778ee8b9
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
class User < ActiveRecord::Base has_many :tasks has_one :profile acts_as_api api_accessible :name_only do |t| t.add :first_name t.add :last_name end api_accessible :only_full_name do |t| t.add :full_name end api_accessible :rename_last_name do |t| t.add :last_name, :as => :family_name end api_accessible :rename_full_name do |t| t.add :full_name, :as => :other_full_name end api_accessible :with_former_value do |t| t.add :first_name t.add :last_name end api_accessible :age_and_first_name, :extend => :with_former_value do |t| t.add :age t.remove :last_name end api_accessible :calling_a_proc do |t| t.add Proc.new{|model| model.full_name.upcase }, :as => :all_caps_name t.add Proc.new{ Time.now.class.to_s }, :as => :without_param end api_accessible :calling_a_lambda do |t| t.add lambda{|model| model.full_name.upcase }, :as => :all_caps_name t.add lambda{ Time.now.class.to_s }, :as => :without_param end User.api_accessible :include_tasks do |t| t.add :tasks end api_accessible :include_profile do |t| t.add :profile end api_accessible :other_sub_template do |t| t.add :first_name t.add :tasks, :template => :other_template end api_accessible :include_completed_tasks do |t| t.add "tasks.completed.all", :as => :completed_tasks end api_accessible :sub_node do |t| t.add Hash[:foo => :say_something], :as => :sub_nodes end api_accessible :nested_sub_node do |t| t.add Hash[:foo, Hash[:bar, :last_name]], :as => :sub_nodes end api_accessible :nested_sub_hash do |t| t.add :sub_hash end def full_name '' << first_name.to_s << ' ' << last_name.to_s end def say_something "something" end def sub_hash { :foo => "bar", :hello => "world" } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts_as_api-0.3.2 | spec/rails_app/app/models/user.rb |